taechasith commited on
Commit
4fcaa47
·
verified ·
1 Parent(s): c5f18ae

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -41
app.py DELETED
@@ -1,41 +0,0 @@
1
- import gradio as gr
2
- from transformers import pipeline
3
- from PIL import Image
4
-
5
- # 1) Load a pretrained image-based facial emotion model from Hugging Face
6
- # The "mehdi-wasi/facial_emotion_recognition" model is an example.
7
- # You can search "emotion", "FER" or "facial expression" on huggingface.co/models
8
- emotion_pipeline = pipeline(
9
- task="image-classification",
10
- model="mehdi-wasi/facial_emotion_recognition"
11
- )
12
-
13
- # 2) Define a function to handle image input and return predictions
14
- def predict_emotion(image: Image.Image):
15
- """
16
- Takes a PIL image, uses the emotion_pipeline to get predictions,
17
- and returns them as a list of {label, score}.
18
- """
19
- # The pipeline will produce a list of predictions sorted by confidence
20
- predictions = emotion_pipeline(image)
21
-
22
- # We can return the raw pipeline output or we can format it
23
- # e.g., only return top label or return them all
24
- # Let’s return them all for clarity.
25
- return predictions
26
-
27
- # 3) Build the Gradio interface
28
- demo = gr.Interface(
29
- fn=predict_emotion,
30
- inputs=gr.Image(type="pil"), # user uploads an image (PIL format)
31
- outputs="json", # we’ll return the pipeline’s JSON predictions
32
- title="Quantum Emotion Detection",
33
- description="""
34
- **QuantumEmotion** - A simple demo that uses a Hugging Face model to classify
35
- facial emotions. Upload an image with a face, and you'll see predicted emotions.
36
- """
37
- )
38
-
39
- # 4) Launch the app (Gradio automatically does this on Spaces)
40
- if __name__ == "__main__":
41
- demo.launch()