Spaces:
Running
Running
abrar-adnan
commited on
Commit
•
ed2cf11
1
Parent(s):
964aa5f
Update app.py
Browse files
app.py
CHANGED
@@ -171,6 +171,8 @@ def video_processing(video_file, encoded_video):
|
|
171 |
|
172 |
# Modify 'sad' key to 'sadness'
|
173 |
video_emotions['sadness'] = video_emotions.pop('sad')
|
|
|
|
|
174 |
|
175 |
final_result_dict = {
|
176 |
"gaze_percentage" : gaze_percentage,
|
@@ -180,6 +182,17 @@ def video_processing(video_file, encoded_video):
|
|
180 |
"text_sentiment" : text_sentiment
|
181 |
}
|
182 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
183 |
return final_result_dict
|
184 |
|
185 |
|
|
|
171 |
|
172 |
# Modify 'sad' key to 'sadness'
|
173 |
video_emotions['sadness'] = video_emotions.pop('sad')
|
174 |
+
|
175 |
+
|
176 |
|
177 |
final_result_dict = {
|
178 |
"gaze_percentage" : gaze_percentage,
|
|
|
182 |
"text_sentiment" : text_sentiment
|
183 |
}
|
184 |
|
185 |
+
for item in final_result_dict['data']:
|
186 |
+
emotions = item['face_emotion']
|
187 |
+
top_emotions = dict(sorted(emotions.items(), key=lambda x: x[1], reverse=True)[:3])
|
188 |
+
item['face_emotion'] = top_emotions
|
189 |
+
|
190 |
+
# Update the text_emotion data
|
191 |
+
for item in final_result_dict['data']:
|
192 |
+
emotions = item['text_emotion']
|
193 |
+
top_emotions = sorted(emotions, key=lambda x: x['score'], reverse=True)[:3]
|
194 |
+
item['text_emotion'] = top_emotions
|
195 |
+
|
196 |
return final_result_dict
|
197 |
|
198 |
|