bearclassifier / app.py
Evan
adding bear classifier learner and gradio changes
b71c515
raw
history blame contribute delete
527 Bytes
from fastai.vision.all import load_learner, Path
import gradio as gr
path = Path()
path.ls(file_exts='.pkl')
learn_inf = load_learner(path/'export.pkl')
categories = ('black', 'grizzly', 'teddy')
def classify_image(img):
pred, idx, probs = learn_inf.predict(img)
return dict(zip(categories, map(float, probs)))
image = gr.Image()
label = gr.Label()
examples = ['grizzly.jpg', 'black.jpg', 'teddy.jpg']
iface = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
iface.launch(inline=False)