EmoPix / app.py
Dharma20's picture
Update app.py
c4527cf verified
raw
history blame
956 Bytes
# %% ../hugging-space-model-app.ipynb 4
from fastai.vision.all import *
import gradio as gr
# %% ../hugging-space-model-app.ipynb 7
learn = load_learner('model.pkl')
# %% ../hugging-space-model-app.ipynb 9
labels = learn.dls.vocab
def classify_image(img):
img = PILImage.create(img)
pred,pred_idx,probs = learn.predict(img)
return {labels[i]: float(probs[i]) for i in range(len(labels))}
# %% ../hugging-space-model-app.ipynb 11
with gr.Blocks(theme=gr.themes.Soft())as demo:
gr.HTML("<center><h1>EmoPix - Facial Expressions Classifier! 😊😞</h1><center>")
gr.Markdown("""##### Classifies human facial expressions from an uploaded image.
<b>Upload images and have funπŸ€—. Classifies facial expressions with 75% accuracy</b>""")
gr.Interface(fn=classify_image,
inputs=gr.components.Image(),
outputs=gr.components.Label(show_label=True,num_top_classes=3))
demo.launch(inline=False)