Spaces:
Runtime error
Runtime error
File size: 622 Bytes
e462c59 2cca981 e462c59 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
__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)
|