23A475R commited on
Commit
132b5af
1 Parent(s): d2006b7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -42,14 +42,20 @@ def predict(frame_or_path):
42
  return frame, {emotion: float(prob) for emotion, prob in zip(EMOTIONS, preds)}
43
 
44
  # Define input and output components for Gradio
45
- image_input = gr.components.Image(sources=["webcam", "upload"], label="Your face")
46
- image_output = gr.components.Image(label="Predicted Emotion")
47
- label_output = gr.components.Label(num_top_classes=2, label="Top 2 Probabilities")
 
 
 
 
 
 
48
 
49
  # Launch the Gradio interface
50
  title = "Facial Emotion Recognition"
51
  description = "How well can this model predict your emotions? Take a picture with your webcam, or upload an image, and it will guess if you are happy, sad, angry, disgusted, scared, surprised, or neutral."
52
  thumbnail = "https://raw.githubusercontent.com/gradio-app/hub-emotion-recognition/master/thumbnail.png"
53
 
54
- gr.Interface(fn=predict, inputs=image_input, outputs=[image_output, label_output],
55
  title=title, description=description, thumbnail=thumbnail).launch()
 
42
  return frame, {emotion: float(prob) for emotion, prob in zip(EMOTIONS, preds)}
43
 
44
  # Define input and output components for Gradio
45
+
46
+ image_input = [
47
+ gr.components.Image(sources="webcam", label="Your face"),
48
+ gr.components.File(label="Upload Image or Video")
49
+ ]
50
+ output = [
51
+ gr.components.Image(label="Predicted Emotion"),
52
+ gr.components.Label(num_top_classes=2, label="Top 2 Probabilities")
53
+ ]
54
 
55
  # Launch the Gradio interface
56
  title = "Facial Emotion Recognition"
57
  description = "How well can this model predict your emotions? Take a picture with your webcam, or upload an image, and it will guess if you are happy, sad, angry, disgusted, scared, surprised, or neutral."
58
  thumbnail = "https://raw.githubusercontent.com/gradio-app/hub-emotion-recognition/master/thumbnail.png"
59
 
60
+ gr.Interface(fn=predict, inputs=image_input, outputs=output,
61
  title=title, description=description, thumbnail=thumbnail).launch()