Spaces:
Runtime error
Runtime error
# AUTOGENERATED! DO NOT EDIT! File to edit: bear_detector.ipynb. | |
# %% auto 0 | |
__all__ = ['learn_inf', 'image', 'label', 'iface', 'classify_image'] | |
# %% bear_detector.ipynb 2 | |
from fastbook import load_learner | |
import gradio as gr | |
# %% bear_detector.ipynb 16 | |
learn_inf = load_learner('bears.pkl') | |
# %% bear_detector.ipynb 17 | |
def classify_image(img): | |
pred, idx, probs = learn_inf.predict(img) | |
return dict(zip(learn_inf.dls.vocab, map(float, probs))) | |
# %% bear_detector.ipynb 18 | |
image = gr.inputs.Image(shape=(192,192)) | |
label = gr.outputs.Label() | |
iface = gr.Interface(fn=classify_image, inputs=image, outputs=label) | |
iface.launch(inline=False) | |