Spaces:
Sleeping
Sleeping
Evan
commited on
Commit
·
b71c515
1
Parent(s):
c8932d6
adding bear classifier learner and gradio changes
Browse files- app.py +14 -4
- black.jpg +0 -0
- export.pkl +3 -0
- grizzly.jpg +0 -0
- teddy.jpg +0 -0
app.py
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
|
|
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastai.vision.all import load_learner, Path
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
+
path = Path()
|
| 5 |
+
path.ls(file_exts='.pkl')
|
| 6 |
+
learn_inf = load_learner(path/'export.pkl')
|
| 7 |
|
| 8 |
+
categories = ('black', 'grizzly', 'teddy')
|
| 9 |
+
def classify_image(img):
|
| 10 |
+
pred, idx, probs = learn_inf.predict(img)
|
| 11 |
+
return dict(zip(categories, map(float, probs)))
|
| 12 |
+
|
| 13 |
+
image = gr.Image()
|
| 14 |
+
label = gr.Label()
|
| 15 |
+
examples = ['grizzly.jpg', 'black.jpg', 'teddy.jpg']
|
| 16 |
+
iface = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
| 17 |
+
iface.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:e1fc8d19450493a39ce3e6264bb79dff62c6b85efefd87bd61842b086e37fb72
|
| 3 |
+
size 46969598
|
grizzly.jpg
ADDED
|
teddy.jpg
ADDED
|