Sephfox commited on
Commit
b58817e
·
verified ·
1 Parent(s): ddc2af9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -2
app.py CHANGED
@@ -156,8 +156,7 @@ def predict_emotion(context):
156
  emotion_prediction_pipeline = pipeline('text-classification', model=emotion_prediction_model, tokenizer=emotion_prediction_tokenizer, top_k=None)
157
  predictions = emotion_prediction_pipeline(context)
158
  emotion_scores = predictions[0]
159
- sorted_scores = sorted(emotion_scores.items(), key=lambda x: x[1], reverse=True)
160
- emotion_pred = sorted_scores[0][0]
161
  return emotion_pred
162
 
163
  def generate_text(prompt, max_length=100, emotion=None):
 
156
  emotion_prediction_pipeline = pipeline('text-classification', model=emotion_prediction_model, tokenizer=emotion_prediction_tokenizer, top_k=None)
157
  predictions = emotion_prediction_pipeline(context)
158
  emotion_scores = predictions[0]
159
+ emotion_pred = emotion_classes[np.argmax(emotion_scores)]
 
160
  return emotion_pred
161
 
162
  def generate_text(prompt, max_length=100, emotion=None):