Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -46,15 +46,14 @@ emotion_classes = pd.Categorical(df['emotion']).categories
|
|
46 |
emotion_prediction_model = AutoModelForSequenceClassification.from_pretrained("bhadresh-savani/distilbert-base-uncased-emotion")
|
47 |
|
48 |
# Lazy loading for the fine-tuned language model
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
return _finetuned_lm_tokenizer, _finetuned_lm_model
|
58 |
|
59 |
# Enhanced Emotional States
|
60 |
emotions = {
|
|
|
46 |
emotion_prediction_model = AutoModelForSequenceClassification.from_pretrained("bhadresh-savani/distilbert-base-uncased-emotion")
|
47 |
|
48 |
# Lazy loading for the fine-tuned language model
|
49 |
+
def predict_emotion(context):
|
50 |
+
tokenizer = AutoTokenizer.from_pretrained("bhadresh-savani/distilbert-base-uncased-emotion")
|
51 |
+
emotion_prediction_pipeline = pipeline('text-classification', model=emotion_prediction_model, tokenizer=tokenizer, return_all_scores=True)
|
52 |
+
predictions = emotion_prediction_pipeline(context)
|
53 |
+
emotion_scores = predictions[0]
|
54 |
+
emotion_pred = max(emotion_scores, key=emotion_scores.get)
|
55 |
+
return emotion_pred
|
56 |
+
|
|
|
57 |
|
58 |
# Enhanced Emotional States
|
59 |
emotions = {
|