Spaces:
Sleeping
Sleeping
File size: 611 Bytes
97bdf4b 62748ed 97bdf4b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
from fastai.vision.all import *
import gradio as gr
def emotion(x): return x[0].isupper()
learn = load_learner('emotion_classifier_model.pkl')
categories = ('angry', 'anxious', 'calm', 'disgusted','happy', 'sad', 'scared')
def classify_images(img):
pred,idx,probs = learn.predict(img)
return dict(zip(categories, map(float,probs)))
image = gr.Image(shape=(192,192))
label = gr.Label()
examples = ['emotions/scared.jpg', 'emotions/happy.jpg', 'emotions/sad.jpg', 'emotions/angry.jpg']
intf = gr.Interface(fn=classify_images, inputs=image, outputs=label, examples=examples)
intf.launch(inline=False) |