Spaces:
Sleeping
Sleeping
# AUTOGENERATED! DO NOT EDIT! File to edit: gundam_or_zaku.ipynb. | |
# %% auto 0 | |
__all__ = ['learner', 'categories', 'image', 'label', 'examples', 'intf', 'classify_image'] | |
# %% gundam_or_zaku.ipynb 1 | |
from fastai.vision.all import * | |
import gradio as gr | |
# %% gundam_or_zaku.ipynb 3 | |
learner = load_learner('model.pkl') | |
# %% gundam_or_zaku.ipynb 5 | |
categories = ('Gundam', 'Zaku') | |
def classify_image(img): | |
pred, idx, probs = learner.predict(img) | |
return dict(zip(categories, map(float, probs))) | |
# %% gundam_or_zaku.ipynb 8 | |
image = gr.inputs.Image(shape=(192, 192)) | |
label = gr.outputs.Label() | |
examples = ['gundam.png', 'zaku.png'] | |
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples) | |
intf.launch(inline=False) | |