Spaces:
Runtime error
Runtime error
amaity
commited on
Commit
·
1781245
1
Parent(s):
67671b7
add application file
Browse files- .gitattributes +1 -0
- app.ipynb +0 -0
- app.py +23 -4
.gitattributes
CHANGED
@@ -29,3 +29,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
29 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
30 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
31 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
29 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
30 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
31 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
32 |
+
/Users/amaity/learn/bike-classification/export.pkl filter=lfs diff=lfs merge=lfs -text
|
app.ipynb
ADDED
The diff for this file is too large to render.
See raw diff
|
|
app.py
CHANGED
@@ -1,7 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
|
|
1 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: ../app.ipynb.
|
2 |
+
|
3 |
+
# %% auto 0
|
4 |
+
__all__ = ['learn', 'categories', 'image', 'label', 'examples', 'intf', 'classify_image']
|
5 |
+
|
6 |
+
# %% ../app.ipynb 4
|
7 |
+
from fastai.vision.all import *
|
8 |
import gradio as gr
|
9 |
|
10 |
+
# %% ../app.ipynb 6
|
11 |
+
learn = load_learner('export.pkl')
|
12 |
+
|
13 |
+
# %% ../app.ipynb 8
|
14 |
+
categories = ('BMX', 'mountain bike', 'road bike')
|
15 |
+
|
16 |
+
def classify_image(img):
|
17 |
+
pred, idx, probs = learn.predict(img)
|
18 |
+
return dict(zip(categories, map(float, probs)))
|
19 |
+
|
20 |
+
# %% ../app.ipynb 14
|
21 |
+
image = gr.inputs.Image(shape=(512, 512))
|
22 |
+
label = gr.outputs.Label()
|
23 |
+
examples = ['road_bike.jpg', 'mountain_bike.jpg', 'BMX.jpg']
|
24 |
|
25 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
26 |
+
intf.launch(inline=False)
|