Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
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",
|