layai commited on
Commit
8863b99
·
1 Parent(s): f76b43c

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from huggingface_hub import from_pretrained_keras
3
+ import numpy as np
4
+ import tensorflow as tf
5
+
6
+ def predict_emotion(face):
7
+ new_face_arr = np.array(face)
8
+ new_img = tf.expand_dims(new_face_arr,0)
9
+ model = from_pretrained_keras("layai/emotion-detection-model")
10
+ single_data = model.predict(new_img)
11
+ single_data = single_data[0]
12
+ return np.argmax(single_data)
13
+
14
+ input = gr.inputs.Image(shape=(48, 48))
15
+ output = gr.outputs.Textbox(label='Predicted Emotion')
16
+ iface = gr.Interface( fn=predict_emotion,
17
+ inputs=input,
18
+ outputs=output,
19
+ capture_session=True)
20
+
21
+ iface.launch()