SamanthaStorm commited on
Commit
68f445c
·
verified ·
1 Parent(s): a752145

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -9,7 +9,11 @@ import io
9
  from PIL import Image
10
  from datetime import datetime
11
  from transformers import pipeline as hf_pipeline # prevent name collision with gradio pipeline
12
-
 
 
 
 
13
  # Emotion model (no retraining needed)
14
  emotion_pipeline = hf_pipeline(
15
  "text-classification",
 
9
  from PIL import Image
10
  from datetime import datetime
11
  from transformers import pipeline as hf_pipeline # prevent name collision with gradio pipeline
12
+ def get_emotion_profile(text):
13
+ emotions = emotion_pipeline(text)
14
+ if isinstance(emotions, list) and isinstance(emotions[0], list):
15
+ emotions = emotions[0]
16
+ return {e['label'].lower(): round(e['score'], 3) for e in emotions}
17
  # Emotion model (no retraining needed)
18
  emotion_pipeline = hf_pipeline(
19
  "text-classification",