# import gradio as gr | |
# | |
# def greet(name): | |
# return "Hello " + name + "!!" | |
# | |
# demo = gr.Interface(fn=greet, inputs="text", outputs="text") | |
# demo.launch(share=True) | |
# AUTOGENERATED! DO NOT EDIT! File to edit: inference-face-crop-model.ipynb. | |
# %% auto 0 | |
__all__ = ['learner', 'categories', 'classify_image'] | |
# %% inference-face-crop-model.ipynb 10 | |
from fastai.vision.all import * | |
import gradio as gr | |
learner = load_learner('./face-crop-model.pkl') | |
categories = ('happy', 'other') | |
def classify_image(img): | |
# img = img["image"] | |
# print(img) | |
pred, idx, probs = learner.predict(img) | |
return dict(zip(categories, map(float, probs))) | |
image = gr.Image(width=192, height=192) | |
label = gr.Label() | |
examples = ['happy.png', "happy2.png", "happy3.png", "happy4.png", 'other.png', 'other2.png', 'other3.png', 'other4.png', 'other5.png',] | |
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples, description="Use an image cropped around face for better performance") | |
intf.launch(inline=False, share=True) | |