Spaces:
Sleeping
Sleeping
__all__ = ['is_spido', 'learn', 'classify_image', 'categories', 'image', 'label', 'examples', 'intf'] | |
# Cell | |
from fastai.vision.all import * | |
import gradio as gr | |
def is_spido(x): return x[0].isupper() | |
# Cell | |
learn = load_learner('model.pkl') | |
# Cell | |
categories = ('spiderman', 'scofield') | |
def classify_image(img): | |
pred,idx,probs = learn.predict(img) | |
return dict(zip(categories, map(float,probs))) | |
# Cell | |
image = gr.Image() | |
label = gr.Label() | |
examples = ['scofield.png', 'spiderman.png', 'spido-scofield.png'] | |
#intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples) | |
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples) | |
intf.launch(inline=False, share=True) |