Spaces:
Sleeping
Sleeping
Marcel Medak
commited on
Commit
·
2ef3dbb
1
Parent(s):
3b6dcf7
simple bear classifier
Browse files- .gitattributes +1 -0
- app.ipynb +0 -0
- app.py +23 -4
- black.jpg +0 -0
- export.pkl +3 -0
- grizzly.jpg +0 -0
- teddy.jpg +0 -0
.gitattributes
CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
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 2
|
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 = ('Black Bear', 'Grizzly Bear', 'Teddy Bear')
|
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 10
|
21 |
+
image = gr.components.Image(width=192, height=192)
|
22 |
+
label = gr.components.Label()
|
23 |
+
examples = ['black.jpg', 'grizzly.jpg', 'teddy.jpg']
|
24 |
|
25 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
26 |
+
intf.launch(inline=False)
|
black.jpg
ADDED
![]() |
export.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:900becfe7a57c44636ebb8c26942b9cb17c22586f59ceff8deea216f6a4ce0d0
|
3 |
+
size 46974590
|
grizzly.jpg
ADDED
![]() |
teddy.jpg
ADDED
![]() |