Update app.py
Browse files
app.py
CHANGED
|
@@ -6,6 +6,8 @@ import spacy
|
|
| 6 |
import nltk
|
| 7 |
from nltk.stem import WordNetLemmatizer
|
| 8 |
from spacy.lang.en.stop_words import STOP_WORDS
|
|
|
|
|
|
|
| 9 |
|
| 10 |
# 1. Setup NLTK and SpaCy dependencies
|
| 11 |
try:
|
|
@@ -55,6 +57,7 @@ def fully_cleaned(text):
|
|
| 55 |
return ' '.join(tokens)
|
| 56 |
|
| 57 |
# 5. Prediction function
|
|
|
|
| 58 |
def predict_emotion(text):
|
| 59 |
cleaned_text = fully_cleaned(text)
|
| 60 |
text_tfidf = tfidf_vectorizer.transform([cleaned_text])
|
|
@@ -70,6 +73,7 @@ iface = gr.Interface(
|
|
| 70 |
description="Enter a sentence to classify its emotion (sadness, joy, love, anger, fear, surprise)."
|
| 71 |
)
|
| 72 |
|
|
|
|
| 73 |
# Launch the interface
|
| 74 |
if __name__ == "__main__":
|
| 75 |
iface.launch()
|
|
|
|
| 6 |
import nltk
|
| 7 |
from nltk.stem import WordNetLemmatizer
|
| 8 |
from spacy.lang.en.stop_words import STOP_WORDS
|
| 9 |
+
import spaces
|
| 10 |
+
|
| 11 |
|
| 12 |
# 1. Setup NLTK and SpaCy dependencies
|
| 13 |
try:
|
|
|
|
| 57 |
return ' '.join(tokens)
|
| 58 |
|
| 59 |
# 5. Prediction function
|
| 60 |
+
@spaces.GPU
|
| 61 |
def predict_emotion(text):
|
| 62 |
cleaned_text = fully_cleaned(text)
|
| 63 |
text_tfidf = tfidf_vectorizer.transform([cleaned_text])
|
|
|
|
| 73 |
description="Enter a sentence to classify its emotion (sadness, joy, love, anger, fear, surprise)."
|
| 74 |
)
|
| 75 |
|
| 76 |
+
|
| 77 |
# Launch the interface
|
| 78 |
if __name__ == "__main__":
|
| 79 |
iface.launch()
|