Spaces:
Sleeping
Sleeping
Michela Ledwidge
commited on
Commit
β’
aa501e9
1
Parent(s):
3cd3e8b
refactor for autogen code
Browse files- app.py +13 -14
- black.jpg β examples/black.jpg +0 -0
- grizzly.jpg β examples/grizzly.jpg +0 -0
- teddy.jpg β examples/teddy.jpg +0 -0
- export.pkl β model.pkl +2 -2
app.py
CHANGED
@@ -1,30 +1,29 @@
|
|
1 |
-
|
2 |
-
'classify_image',
|
3 |
-
'categories',
|
4 |
-
'image',
|
5 |
-
'label',
|
6 |
-
'examples',
|
7 |
-
'intf'
|
8 |
-
]
|
9 |
|
|
|
|
|
|
|
|
|
10 |
from fastai.vision.all import *
|
11 |
import gradio as gr
|
12 |
|
13 |
-
|
14 |
-
return x[0].isupper()
|
15 |
-
|
16 |
categories = ('black','grizzly','teddy')
|
17 |
|
|
|
18 |
def classify_image(img):
|
19 |
pred,idx, probs = learn.predict(img)
|
20 |
return dict(zip(categories, map(float,probs)))
|
21 |
|
22 |
-
|
|
|
23 |
|
24 |
image = gr.components.Image(width=224, height=224)
|
25 |
label = gr.components.Label()
|
26 |
-
|
|
|
|
|
|
|
27 |
|
28 |
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label,examples=examples)
|
29 |
intf.launch(inline=False)
|
30 |
-
|
|
|
1 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: ../02_production.ipynb.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
+
# %% auto 0
|
4 |
+
__all__ = ['categories', 'learn', 'image', 'label', 'file_list', 'stem', 'examples', 'intf', 'classify_image']
|
5 |
+
|
6 |
+
# %% ../02_production.ipynb 53
|
7 |
from fastai.vision.all import *
|
8 |
import gradio as gr
|
9 |
|
10 |
+
# %% ../02_production.ipynb 55
|
|
|
|
|
11 |
categories = ('black','grizzly','teddy')
|
12 |
|
13 |
+
# %% ../02_production.ipynb 56
|
14 |
def classify_image(img):
|
15 |
pred,idx, probs = learn.predict(img)
|
16 |
return dict(zip(categories, map(float,probs)))
|
17 |
|
18 |
+
# %% ../02_production.ipynb 58
|
19 |
+
learn = load_learner('model.pkl')
|
20 |
|
21 |
image = gr.components.Image(width=224, height=224)
|
22 |
label = gr.components.Label()
|
23 |
+
|
24 |
+
file_list = ['grizzly.jpg', 'black.jpg', 'teddy.jpg']
|
25 |
+
stem = 'examples/'
|
26 |
+
examples = list(map(lambda x: stem + x, file_list))
|
27 |
|
28 |
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label,examples=examples)
|
29 |
intf.launch(inline=False)
|
|
black.jpg β examples/black.jpg
RENAMED
File without changes
|
grizzly.jpg β examples/grizzly.jpg
RENAMED
File without changes
|
teddy.jpg β examples/teddy.jpg
RENAMED
File without changes
|
export.pkl β model.pkl
RENAMED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:58eced61a5122ed4577b0d8da4deae6aa58d8d10bc6a100b4df172fd627a0262
|
3 |
+
size 46965298
|