Spaces:
Sleeping
Sleeping
# AUTOGENERATED! DO NOT EDIT! File to edit: ../dog-breeds.ipynb. | |
# %% auto 0 | |
__all__ = ['learn_inf', 'categories', 'image', 'label', 'examples', 'intf', 'classify_image'] | |
# %% ../dog-breeds.ipynb 2 | |
from fastai import * | |
from fastai.vision.all import * | |
import gradio as gr | |
# %% ../dog-breeds.ipynb 13 | |
# Load model wherever you plan to use it for inference | |
learn_inf = load_learner('export2.pkl') | |
# %% ../dog-breeds.ipynb 15 | |
categories = dls.vocab | |
def classify_image(img): | |
pred, idx, probs = learn_inf.predict(img) | |
return dict(zip(categories, map(float,probs))) | |
# %% ../dog-breeds.ipynb 16 | |
image = gr.Image(shape=(192,192)) | |
label = gr.Label() | |
examples = ['dog.jpg', 'cat.jpg'] | |
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples) | |
intf.launch(inline=True, share=True) |