Spaces:
Sleeping
Sleeping
File size: 630 Bytes
8863b99 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | 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() |