Spaces:
Runtime error
Runtime error
# AUTOGENERATED! DO NOT EDIT! File to edit: ../Model2.5Run.ipynb. | |
# %% auto 0 | |
__all__ = ['learn', 'categories', 'image', 'label', 'examples', 'intf', 'what_direction', 'filename_to_class', 'classify_images'] | |
# %% ../Model2.5Run.ipynb 1 | |
from fastai.vision.all import * | |
import gradio as gr | |
def what_direction(x): return x[0].isupper() | |
def filename_to_class(filename: str) -> str: | |
return filename.split("_")[0] | |
# %% ../Model2.5Run.ipynb 3 | |
learn = load_learner('learner.pkl') | |
# %% ../Model2.5Run.ipynb 5 | |
categories = ('forward', 'left', 'right') | |
def classify_images(img): | |
pred,idx,probs = learn.predict(img) | |
return dict(zip(categories, map(float,probs))) | |
# %% ../Model2.5Run.ipynb 7 | |
image = gr.inputs.Image(shape=(192,192)) | |
label = gr.outputs.Label() | |
examples = ['IMG_1167.JPG', 'IMG_0968.JPG', 'IMG_1251.JPG', 'IMG_1365.JPG', 'IMG_1437.JPG'] | |
intf = gr.Interface(fn=classify_images, inputs=image, outputs=label, examples=examples) | |
intf.launch(inline=False) | |