Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -10,6 +10,11 @@ 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",
|
@@ -332,11 +337,8 @@ def compute_abuse_score(matched_scores, sentiment):
|
|
332 |
adjusted_score += 10
|
333 |
|
334 |
return min(adjusted_score, 100)
|
335 |
-
|
336 |
-
|
337 |
-
if isinstance(emotions, list) and isinstance(emotions[0], list):
|
338 |
-
emotions = emotions[0]
|
339 |
-
return {e['label'].lower(): round(e['score'], 3) for e in emotions}
|
340 |
def analyze_single_message(text, thresholds):
|
341 |
motif_hits, matched_phrases = detect_motifs(text)
|
342 |
|
|
|
10 |
from datetime import datetime
|
11 |
from transformers import pipeline as hf_pipeline # prevent name collision with gradio pipeline
|
12 |
|
13 |
+
def get_emotion_profile(text):
|
14 |
+
emotions = emotion_pipeline(text)
|
15 |
+
if isinstance(emotions, list) and isinstance(emotions[0], list):
|
16 |
+
emotions = emotions[0]
|
17 |
+
return {e['label'].lower(): round(e['score'], 3) for e in emotions}
|
18 |
# Emotion model (no retraining needed)
|
19 |
emotion_pipeline = hf_pipeline(
|
20 |
"text-classification",
|
|
|
337 |
adjusted_score += 10
|
338 |
|
339 |
return min(adjusted_score, 100)
|
340 |
+
|
341 |
+
|
|
|
|
|
|
|
342 |
def analyze_single_message(text, thresholds):
|
343 |
motif_hits, matched_phrases = detect_motifs(text)
|
344 |
|