Spaces:
Sleeping
Sleeping
# AUTOGENERATED! DO NOT EDIT! File to edit: ../00_core.ipynb. | |
# %% auto 0 | |
__all__ = ['learn_inf', 'categories', 'image', 'label', 'examples', 'intf', 'classify_image'] | |
# %% ../00_core.ipynb 3 | |
from fastai.vision.all import * | |
# %% ../00_core.ipynb 17 | |
learn_inf = load_learner('export.pkl') | |
# %% ../00_core.ipynb 21 | |
import gradio as gr | |
categories = ['aeroplane', 'bicycle', 'bird', 'boat', 'bottle', | |
'bus', 'car', 'cat', 'chair', 'cow', 'diningtable', 'dog', | |
'horse', 'motorbike', 'person', 'pottedplant', 'sheep', | |
'sofa', 'train', 'tvmonitor'] | |
def classify_image(img): | |
red, idx, probs = learn_inf.predict(img) | |
return dict(zip(categories, map(float, probs))) | |
image = gr.inputs.Image(shape=(192,192)) | |
label = gr.outputs.Label() | |
examples = ['sheep.PNG', 'chair_diningtable.PNG', 'car_person.PNG'] | |
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples) | |
intf.launch(inline=False) | |