Spaces:
Runtime error
Runtime error
File size: 586 Bytes
9a0c897 a8b487e 9a0c897 a2ea8b4 9a0c897 e34757f 9a0c897 a2ea8b4 9a0c897 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
from tensorflow import keras
import gradio as gr
model = keras.models.load_model('facial_expression1.h5')
class_names = ['angry', 'disgust', 'fear', 'happy', 'neutral', 'sad', 'surprise']
def predict_input_image(img):
img_4d=img.reshape(-1,48,48,1)
prediction=model.predict(img_4d)[0]
return {class_names[i]: float(prediction[i]) for i in range(len(class_names))}
image = gr.inputs.Image(shape=(48,48))
label = gr.outputs.Label(num_top_classes=len(class_names))
gr.Interface(fn=predict_input_image, inputs=image, outputs=label,interpretation='default').launch(debug='True')
|