Spaces:
Runtime error
Runtime error
# AUTOGENERATED! DO NOT EDIT! File to edit: ../canals_classification.ipynb. | |
# %% auto 0 | |
__all__ = ['learn', 'labels', 'demo', 'predict'] | |
# %% ../canals_classification.ipynb 1 | |
import gradio as gr | |
from fastai.vision.all import * | |
# %% ../canals_classification.ipynb 2 | |
learn = load_learner("canals.pkl") | |
import fastbook | |
fastbook.setup_book() | |
from fastbook import * | |
from fastai.vision.widgets import * | |
# %% ../canals_classification.ipynb 6 | |
labels = learn.dls.vocab | |
def predict(img): | |
img = PILImage.create(img) | |
pred,pred_idx,probs = learn.predict(img) | |
return {labels[i]: float(probs[i]) for i in range(len(labels))} | |
# %% ../canals_classification.ipynb 8 | |
demo = gr.Interface(fn=predict, inputs="image", outputs="label") | |
demo.launch() | |