Update app.py
Browse files
app.py
CHANGED
@@ -1,10 +1,20 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
|
4 |
+
# Load emotion model from Hugging Face
|
5 |
+
emotion_pipe = pipeline("image-classification", model="dima806/facial_emotions_image_detection")
|
6 |
+
|
7 |
+
def detect_emotion(image):
|
8 |
+
results = emotion_pipe(image)
|
9 |
+
if results:
|
10 |
+
top = results[0]
|
11 |
+
return f"{top['label']} ({100*top['score']:.1f}%)"
|
12 |
+
return "No face detected"
|
13 |
+
|
14 |
+
gr.Interface(
|
15 |
+
fn=detect_emotion,
|
16 |
+
inputs=gr.Image(type="pil"),
|
17 |
+
outputs="text",
|
18 |
+
title="High Accuracy Emotion Detector",
|
19 |
+
description="Powered by dima806/facial_emotions_image_detection (~91% accurate)"
|
20 |
+
).launch()
|