Spaces:
Runtime error
Runtime error
Francesco-A
commited on
Commit
•
3a8154a
1
Parent(s):
009819b
bear_classifier_v1
Browse files- app.py +32 -0
- black.jpg +0 -0
- black_grizzly_teddy.pkl +3 -0
- grizzly.jpg +0 -0
- teddy.jpg +0 -0
app.py
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: .
|
2 |
+
|
3 |
+
# Cell
|
4 |
+
__all__ = ['learn', 'categories', 'classify_image']
|
5 |
+
|
6 |
+
|
7 |
+
# Cell
|
8 |
+
from fastai.vision.widgets import *
|
9 |
+
from fastai.vision.all import *
|
10 |
+
import gradio as gr
|
11 |
+
|
12 |
+
# Cell
|
13 |
+
learn = load_learner("black_grizzly_teddy.pkl")
|
14 |
+
|
15 |
+
# Cell
|
16 |
+
categories = ('Black', 'Grizzly', 'Teddy')
|
17 |
+
def classify_image(img):
|
18 |
+
pred, idx, probs = learn.predict(img)
|
19 |
+
return dict(zip(categories, map(float, probs)))
|
20 |
+
|
21 |
+
# Cell
|
22 |
+
image = gr.components.Image(shape= (192, 192))
|
23 |
+
label = gr.components.Label()
|
24 |
+
examples = ['black.jpg', 'grizzly.jpg', 'teddy.jpg']
|
25 |
+
intf = gr.Interface(fn=classify_image,
|
26 |
+
inputs=image,
|
27 |
+
outputs=label,
|
28 |
+
examples=examples)
|
29 |
+
|
30 |
+
intf.launch(inline=False,
|
31 |
+
# share=True
|
32 |
+
)
|
black.jpg
ADDED
black_grizzly_teddy.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b3b18d7856e84cd91762a42d81d5c9a29a5f7aac799e13a22cb0f96ba6b88ef9
|
3 |
+
size 46970895
|
grizzly.jpg
ADDED
teddy.jpg
ADDED