SamanthaStorm commited on
Commit
a96239e
·
verified ·
1 Parent(s): ede8fe9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -10,11 +10,6 @@ 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
- def get_emotional_tone_tag(emotions, sentiment, patterns, abuse_score, 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",
@@ -130,9 +125,15 @@ ESCALATION_QUESTIONS = [
130
  ("Violence has increased in frequency or severity", 3),
131
  ("Partner monitors your calls/GPS/social media", 2)
132
  ]
133
- tone_tag = get_emotional_tone_tag(emotion_profile, sentiment, threshold_labels, abuse_score, text)
134
 
135
 
 
 
 
 
 
 
 
136
  # 1. Performative Regret
137
  if (
138
  sadness > 0.4 and
 
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",
 
125
  ("Violence has increased in frequency or severity", 3),
126
  ("Partner monitors your calls/GPS/social media", 2)
127
  ]
 
128
 
129
 
130
+ def get_emotional_tone_tag(emotions, sentiment, patterns, abuse_score, text):
131
+ sadness = emotions.get("sadness", 0)
132
+ joy = emotions.get("joy", 0)
133
+ neutral = emotions.get("neutral", 0)
134
+ disgust = emotions.get("disgust", 0)
135
+ anger = emotions.get("anger", 0)
136
+ fear = emotions.get("fear", 0)
137
  # 1. Performative Regret
138
  if (
139
  sadness > 0.4 and