ptoro's picture
Upload app.py
4a8d93f
raw
history blame
674 Bytes
# AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb.
# %% auto 0
__all__ = ['learn', 'labels', 'image', 'label', 'examples', 'intf', 'classify_image']
# %% app.ipynb 1
from fastai.vision.all import *
import gradio as gr
# %% app.ipynb 3
learn = load_learner('eh_native_plants.pkl')
# %% app.ipynb 6
labels = learn.dls.vocab
def classify_image(img):
pred,pred_idx,probs = learn.predict(img)
return dict(zip(labels, map(float, probs)))
# %% app.ipynb 8
image = gr.Image(shape=(192,192))
label = gr.Label()
examples = ['ind_grass.jpg', 'reed.jpg']
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, example=examples)
intf.launch(inline=False)