bears / app.py
EvanMarie's picture
Upload 7 files
db919db
raw
history blame
658 Bytes
__all__ = ['is_cat', 'learner_pets', 'categories', 'classify_pet', 'image', 'label', 'examples', 'intf']
from fastai.vision.all import *
import gradio as gr
learner_bears = load_learner('bears_model.pk1')
categories = ['teddy bear', 'grizzly bear', 'black bear']
def classify_bears(img):
prediction, index, probability = learner_bears.predict(img)
return dict(zip(categories, map(float, probability)))
intf = gr.Interface(fn=classify_bears,
inputs=gr.Image(shape=(192, 192)),
outputs=gr.Label(),
examples=['grizzly_bear.jpeg', 'black_bear.jpeg, 'teddy_bear.jpeg', 'not_sure.jpeg'])
intf.launch(inline=False)