File size: 974 Bytes
e7112be
 
 
 
 
 
 
21f080b
 
e7112be
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21f080b
e7112be
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# 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)