# AUTOGENERATED! DO NOT EDIT! File to edit: . (unless otherwise specified). | |
__all__ = ['is_cat', 'learn', 'classify_image', 'categories', 'inp_img', 'out_label', 'iface'] | |
# Cell | |
from fastai.vision.all import * | |
import gradio as gr | |
# Cell | |
def is_cat(x): return x[0].isupper() | |
# Cell | |
learn = load_learner('model.pkl') | |
# Cell | |
categories = ('Dog', 'Cat') | |
def classify_image(img): | |
pred,idx,probs = learn.predict(img) | |
return dict(zip(categories, map(float,probs))) | |
# Cell | |
inp_img = gr.inputs.Image(shape=(200,200)) | |
out_label = gr.outputs.Label() | |
iface = gr.Interface(fn=classify_image, | |
inputs=inp_img, | |
outputs=out_label, | |
title="Pet classifier") | |
# Cell | |
iface.launch(inline=False) |