Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -46,3 +46,20 @@ iface = gr.Interface(
|
|
| 46 |
|
| 47 |
if __name__ == "__main__":
|
| 48 |
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
|
| 47 |
if __name__ == "__main__":
|
| 48 |
iface.launch()
|
| 49 |
+
def detect_emotion_caption(image):
|
| 50 |
+
results = emotion_model(image)
|
| 51 |
+
top_emotion = results[0]['label'].lower()
|
| 52 |
+
|
| 53 |
+
# Simple caption mapping
|
| 54 |
+
captions = {
|
| 55 |
+
"angry": "he is angry",
|
| 56 |
+
"happy": "he is smiling",
|
| 57 |
+
"sad": "he is crying",
|
| 58 |
+
"disgust": "he looks disgusted",
|
| 59 |
+
"fear": "he looks scared",
|
| 60 |
+
"surprise": "he is surprised",
|
| 61 |
+
"neutral": "he looks neutral",
|
| 62 |
+
"contempt": "he looks contemptuous"
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
return captions.get(top_emotion, f"he looks {top_emotion}")
|