File size: 613 Bytes
d8f64b9
0e3b197
d8f64b9
0e3b197
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import gradio as gr
from transformers import pipeline

# Load emotion model from Hugging Face
emotion_pipe = pipeline("image-classification", model="dima806/facial_emotions_image_detection")

def detect_emotion(image):
    results = emotion_pipe(image)
    if results:
        top = results[0]
        return f"{top['label']} ({100*top['score']:.1f}%)"
    return "No face detected"

gr.Interface(
    fn=detect_emotion,
    inputs=gr.Image(type="pil"),
    outputs="text",
    title="High Accuracy Emotion Detector",
    description="Powered by dima806/facial_emotions_image_detection (~91% accurate)"
).launch()