bear-detector / app.py
chrwittm's picture
uploaded app
8af0813
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/app.ipynb.
# %% auto 0
__all__ = ['learn', 'image', 'lable', 'examples', 'intf', 'classify_image']
# %% ../nbs/app.ipynb 1
from fastai.vision.all import *
import gradio as gr
# %% ../nbs/app.ipynb 3
learn = load_learner('export.pkl')
# %% ../nbs/app.ipynb 7
def classify_image(img):
pred,pred_idx,probs = learn.predict(img)
return dict(zip(learn.dls.vocab, map(float, probs)))
# %% ../nbs/app.ipynb 10
#image = gr.inputs.Image(shape=(192,192))
image = gr.components.Image(shape=(192,192))
#lable = gr.outputs.Label()
lable = gr.components.Label()
examples = ['teddybear.jpg', 'grizzly.jpg', 'blackbear.jpg']
intf = gr.Interface(fn=classify_image, inputs=image, outputs=lable, examples=examples)
intf.launch(inline=False)