bear-classifier / app.py
tiesan's picture
add script to predict bears
25aaf07
raw
history blame contribute delete
505 Bytes
import gradio as gr
from fastai.vision.all import load_learner
learn_inf = load_learner('export.pkl')
categories = ['black', 'grizzly', 'teddy']
image = gr.inputs.Image(shape=(192, 192))
label = gr.outputs.Label()
examples = ['grizzly-bear.jpg', 'teddy-bear.jpg', 'black-bear.jpg']
def classify_img(img):
pred, idx, probs = learn_inf.predict(img)
return dict(zip(categories, map(float, probs)))
iface = gr.Interface(fn=classify_img, inputs=image, outputs=label, examples=examples)
iface.launch()