Rishith2458 commited on
Commit
0e3b197
·
verified ·
1 Parent(s): d8f64b9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -8
app.py CHANGED
@@ -1,10 +1,20 @@
1
  import gradio as gr
 
2
 
3
- with gr.Blocks(fill_height=True) as demo:
4
- with gr.Sidebar():
5
- gr.Markdown("# Inference Provider")
6
- gr.Markdown("This Space showcases the dima806/facial_emotions_image_detection model, served by the hf-inference API. Sign in with your Hugging Face account to use this API.")
7
- button = gr.LoginButton("Sign in")
8
- gr.load("models/dima806/facial_emotions_image_detection", accept_token=button, provider="hf-inference")
9
-
10
- demo.launch()
 
 
 
 
 
 
 
 
 
 
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()