import gradio as gr | |
from fastai.vision.all import * | |
learn = load_learner('model.pkl') | |
categories = ('black','grizzly','teddy') | |
def classify_image(img): | |
prob, idx, probs = learn.predict(img) | |
return dict(zip(categories, map(float, probs))) | |
examples = ['ted.jpeg'] | |
iface = gr.Interface(fn=classify_image, inputs=gr.Image(type="pil"), outputs=gr.Label(num_top_classes=2), examples = examples) | |
iface.launch(inline=False) |