Spaces:
Sleeping
Sleeping
model.py
Browse files- .ipynb_checkpoints/app-checkpoint.py +17 -0
- app.py +14 -4
- model.pkl +3 -0
.ipynb_checkpoints/app-checkpoint.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from fastai.vision.all import *
|
| 3 |
+
|
| 4 |
+
leaner = load_learner('model.pkl')
|
| 5 |
+
categories = ['black', 'grizzly', 'teddy']
|
| 6 |
+
|
| 7 |
+
def predict(img):
|
| 8 |
+
preds,idx,probs = leaner.predict(img)
|
| 9 |
+
return dict(zip(categories,map(float,probs)))
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
demo = gr.Interface(fn=predict,
|
| 14 |
+
inputs=gr.inputs.Image(shape=(224, 224)),
|
| 15 |
+
outputs= gr.outputs.Label()
|
| 16 |
+
)
|
| 17 |
+
demo.launch(inline=false)
|
app.py
CHANGED
|
@@ -1,7 +1,17 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from fastai.vision.all import *
|
| 3 |
|
| 4 |
+
leaner = load_learner('model.pkl')
|
| 5 |
+
categories = ['black', 'grizzly', 'teddy']
|
| 6 |
|
| 7 |
+
def predict(img):
|
| 8 |
+
preds,idx,probs = leaner.predict(img)
|
| 9 |
+
return dict(zip(categories,map(float,probs)))
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
demo = gr.Interface(fn=predict,
|
| 14 |
+
inputs=gr.inputs.Image(shape=(224, 224)),
|
| 15 |
+
outputs= gr.outputs.Label()
|
| 16 |
+
)
|
| 17 |
+
demo.launch(inline=false)
|
model.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c2b4e4ff272d5b27e405baf5fe6e07b3e00a49e9d29c3c5106f1988fdada1f63
|
| 3 |
+
size 46968929
|