Spaces:
Runtime error
Runtime error
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/02_gradio_model.ipynb. | |
# %% auto 0 | |
__all__ = ['learn', 'classify_image'] | |
# %% ../nbs/02_gradio_model.ipynb 2 | |
from fastai.vision.all import * | |
import gradio as gr | |
# %% ../nbs/02_gradio_model.ipynb 3 | |
learn = load_learner('star-wars-character-classifier.pkl') | |
# %% ../nbs/02_gradio_model.ipynb 4 | |
def classify_image(img): | |
pred, idx, probs = learn.predict(img) | |
return dict(zip(learn.dls.vocab.items, map(float, probs))) | |
# %% ../nbs/02_gradio_model.ipynb 8 | |
gr.Interface( | |
classify_image, | |
inputs=gr.inputs.Image(label="Star Wars character", type="filepath"), | |
outputs=gr.outputs.Label(num_top_classes=3), | |
title="Which Star Wars Character It Is?", | |
).launch() | |