Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -74,14 +74,23 @@ def predict_emotion(image):
|
|
| 74 |
emotion = idx2label[predicted]
|
| 75 |
emoji = emotion_emoji.get(emotion, "❓") # Default to "?" if no emoji found
|
| 76 |
return f"{emotion} {emoji}"
|
| 77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
# Create Gradio interface
|
| 79 |
iface = gr.Interface(
|
| 80 |
fn=predict_emotion,
|
| 81 |
-
inputs=gr.Image(type="pil", label="Upload an Image"),
|
| 82 |
-
outputs=gr.Textbox(label="Emotion"),
|
| 83 |
title="PerceptCLIP-Emotions",
|
| 84 |
-
description="This model predicts the emotion evoked by an image and returns the corresponding emoji along with the emotion name."
|
|
|
|
| 85 |
)
|
| 86 |
|
| 87 |
if __name__ == "__main__":
|
|
|
|
| 74 |
emotion = idx2label[predicted]
|
| 75 |
emoji = emotion_emoji.get(emotion, "❓") # Default to "?" if no emoji found
|
| 76 |
return f"{emotion} {emoji}"
|
| 77 |
+
|
| 78 |
+
# Example images (provide local file paths or URLs)
|
| 79 |
+
example_images = [
|
| 80 |
+
"https://img.freepik.com/free-photo/emotive-excited-female-with-dark-skin-crisp-hair-keeps-hands-clenched-fists-exclaims-with-positiveness-as-achieved-success-her-career-opens-mouth-widely-isolated-white-wall_273609-16443.jpg",
|
| 81 |
+
"https://t4.ftcdn.net/jpg/01/18/44/59/360_F_118445958_NtP7tIsD0CBPyG7Uad7Z2KxVWrsfCPjP.jpg",
|
| 82 |
+
"https://apnapestcontrol.ca/wp-content/uploads/2019/02/9.jpg",
|
| 83 |
+
"https://images.pexels.com/photos/1107717/pexels-photo-1107717.jpeg?cs=srgb&dl=pexels-fotios-photos-1107717.jpg&fm=jpg"
|
| 84 |
+
]
|
| 85 |
+
|
| 86 |
# Create Gradio interface
|
| 87 |
iface = gr.Interface(
|
| 88 |
fn=predict_emotion,
|
| 89 |
+
inputs=gr.Image(type="pil", label="Upload an Image"),
|
| 90 |
+
outputs=gr.Textbox(label="Emotion"),
|
| 91 |
title="PerceptCLIP-Emotions",
|
| 92 |
+
description="This model predicts the emotion evoked by an image and returns the corresponding emoji along with the emotion name.",
|
| 93 |
+
examples=example_images # Add example images here
|
| 94 |
)
|
| 95 |
|
| 96 |
if __name__ == "__main__":
|