Spaces:
Sleeping
Sleeping
# AUTOGENERATED! DO NOT EDIT! File to edit: ../app.ipynb. | |
# %% auto 0 | |
__all__ = ['learn', 'categories', 'img', 'label', 'examples', 'intf', 'classify_img'] | |
# %% ../app.ipynb 1 | |
from fastai.vision.all import * | |
import gradio as gr | |
# bean_lesion_re = r'^(.+)_train' | |
# %% ../app.ipynb 3 | |
learn = load_learner('model.pkl') | |
# %% ../app.ipynb 5 | |
categories = ('angular_leaf_spot', 'bean_rust', 'healthy') | |
def classify_img(img): | |
pred, idx, probs = learn.predict(img) | |
return dict(zip(categories, map(float, probs))) | |
# %% ../app.ipynb 7 | |
img = gr.Image() | |
label = gr.Label() | |
examples = ['healthy.jpg', 'angular_leaf_spot.jpg', 'bean_rust.jpg'] | |
intf = gr.Interface(fn=classify_img, inputs=img, outputs=label, examples=examples) | |
intf.launch(inline=False) | |