Spaces:
Runtime error
Runtime error
Francisco Morales
commited on
Commit
•
e7112be
1
Parent(s):
21f080b
ad
Browse files
app.py
CHANGED
@@ -1,7 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
def
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
|
|
1 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: ../Model2.5Run.ipynb.
|
2 |
+
|
3 |
+
# %% auto 0
|
4 |
+
__all__ = ['learn', 'categories', 'image', 'label', 'examples', 'intf', 'what_direction', 'filename_to_class', 'classify_images']
|
5 |
+
|
6 |
+
# %% ../Model2.5Run.ipynb 1
|
7 |
+
from fastai.vision.all import *
|
8 |
import gradio as gr
|
9 |
|
10 |
+
def what_direction(x): return x[0].isupper()
|
11 |
+
|
12 |
+
def filename_to_class(filename: str) -> str:
|
13 |
+
return filename.split("_")[0]
|
14 |
+
|
15 |
+
# %% ../Model2.5Run.ipynb 3
|
16 |
+
learn = load_learner('learner.pkl')
|
17 |
+
|
18 |
+
# %% ../Model2.5Run.ipynb 5
|
19 |
+
categories = ('forward', 'left', 'right')
|
20 |
+
|
21 |
+
def classify_images(img):
|
22 |
+
pred,idx,probs = learn.predict(img)
|
23 |
+
return dict(zip(categories, map(float,probs)))
|
24 |
+
|
25 |
+
# %% ../Model2.5Run.ipynb 7
|
26 |
+
image = gr.inputs.Image(shape=(192,192))
|
27 |
+
label = gr.outputs.Label()
|
28 |
+
examples = ['IMG_1167.JPG', 'IMG_0968.JPG', 'IMG_1251.JPG', 'IMG_1365.JPG', 'IMG_1437.JPG']
|
29 |
|
30 |
+
intf = gr.Interface(fn=classify_images, inputs=image, outputs=label, examples=examples)
|
31 |
+
intf.launch(inline=False)
|