Spaces:
Sleeping
Sleeping
from fastai.vision.all import * | |
import gradio as gr | |
learn = load_learner('model.pkl') | |
categories = {'Dog', 'Cat', 'Bird', 'Koala'} | |
def predict_image(img): | |
pred, pred_idx, probs = learn.predict(img) | |
probs_float = probs[0].item() | |
if probs_float > 0.1: | |
return dict(zip(categories, map(float, probs))) | |
else: | |
return "Not a dog, cat, bird, or koala" | |
image = gr.inputs.Image(shape=(192, 192)) | |
label = gr.outputs.Label() | |
examples = ['dog.jfif', 'cat.jfif', 'bird.jfif', 'koala.jfif'] | |
intf = gr.Interface(fn=predict_image, inputs=image, outputs=label, examples=examples) | |
intf.launch(inline=False) | |