Spaces:
Runtime error
Runtime error
Commit
·
e7a36ee
1
Parent(s):
cc7526c
bear classifier
Browse files- app.py +22 -0
- bearmodel.pkl +3 -0
- blackbear.jpg +0 -0
- grizzly.jpg +0 -0
- model.pkl +3 -0
- requirements.txt +1 -0
- teddy.jpg +0 -0
app.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastai.vision.all import *
|
| 2 |
+
import gradio as gr
|
| 3 |
+
|
| 4 |
+
# def is_cat(x): return x[0].isupper()
|
| 5 |
+
|
| 6 |
+
# Cell
|
| 7 |
+
learn = load_learner('model.pkl')
|
| 8 |
+
|
| 9 |
+
# Cell
|
| 10 |
+
categories = ('Black Bear', 'Grizzly', 'Teddy')
|
| 11 |
+
|
| 12 |
+
def classify_image(img):
|
| 13 |
+
pred,idx,probs = learn.predict(img)
|
| 14 |
+
return dict(zip(categories, map(float,probs)))
|
| 15 |
+
|
| 16 |
+
# Cell
|
| 17 |
+
image = gr.inputs.Image(shape=(192, 192))
|
| 18 |
+
label = gr.outputs.Label()
|
| 19 |
+
examples = ['grizzly.jpg', 'blackbear.jpg', 'teddy.jpg']
|
| 20 |
+
|
| 21 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
| 22 |
+
intf.launch(inline=False)
|
bearmodel.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b4e20034852920aad8f5baa870c60189b896bb0138f65c77e2b947d3b2d66c2d
|
| 3 |
+
size 46983265
|
blackbear.jpg
ADDED
|
grizzly.jpg
ADDED
|
model.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b4e20034852920aad8f5baa870c60189b896bb0138f65c77e2b947d3b2d66c2d
|
| 3 |
+
size 46983265
|
requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
fastai
|
teddy.jpg
ADDED
|