Spaces:
Runtime error
Runtime error
__all__ = ['is_cat', 'learner_pets', 'categories', 'classify_pet', 'image', 'label', 'examples', 'intf'] | |
from fastai.vision.all import * | |
import gradio as gr | |
def is_cat(x): return x[0].isupper() | |
learner_pets = load_learner('cats_dogs.pk1') | |
categories = ['Dog', 'Cat'] | |
def classify_pet(img): | |
prediction, index, probability = learner_pets.predict(img) | |
return dict(zip(categories, map(float, probability))) | |
intf = gr.Interface(fn=classify_pet, | |
inputs=gr.Image(shape=(192, 192)), | |
outputs=gr.Label(), | |
examples=['dog.jpeg', 'cat.png', 'not_sure.jpeg']) | |
intf.launch(inline=False) | |