Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from huggingface_hub import from_pretrained_keras | |
| import numpy as np | |
| import tensorflow as tf | |
| def predict_emotion(face): | |
| new_face_arr = np.array(face) | |
| new_img = tf.expand_dims(new_face_arr,0) | |
| model = from_pretrained_keras("layai/emotion-detection-model") | |
| single_data = model.predict(new_img) | |
| single_data = single_data[0] | |
| return np.argmax(single_data) | |
| input = gr.inputs.Image(shape=(48, 48)) | |
| output = gr.outputs.Textbox(label='Predicted Emotion') | |
| iface = gr.Interface( fn=predict_emotion, | |
| inputs=input, | |
| outputs=output, | |
| capture_session=True) | |
| iface.launch() |