Spaces:
Runtime error
Runtime error
Commit
·
aeed9eb
1
Parent(s):
e491b5f
another test
Browse files
README.md
CHANGED
|
@@ -4,7 +4,7 @@ emoji: 👁
|
|
| 4 |
colorFrom: purple
|
| 5 |
colorTo: red
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version:
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: apache-2.0
|
|
|
|
| 4 |
colorFrom: purple
|
| 5 |
colorTo: red
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 3.50.2
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: apache-2.0
|
app.py
CHANGED
|
@@ -1,25 +1,19 @@
|
|
| 1 |
-
__all__ = ['learn', 'classify_image', 'categories', 'image', 'label', 'examples', 'intf']
|
| 2 |
-
|
| 3 |
-
# Cell
|
| 4 |
from fastai.vision.all import *
|
| 5 |
import gradio as gr
|
| 6 |
-
import timm
|
| 7 |
|
| 8 |
-
|
|
|
|
| 9 |
learn = load_learner('model.pkl')
|
| 10 |
|
| 11 |
-
|
| 12 |
-
categories = learn.dls.vocab
|
| 13 |
|
| 14 |
def classify_image(img):
|
| 15 |
pred,idx,probs = learn.predict(img)
|
| 16 |
return dict(zip(categories, map(float,probs)))
|
| 17 |
|
| 18 |
-
# Cell
|
| 19 |
image = gr.inputs.Image(shape=(192, 192))
|
| 20 |
label = gr.outputs.Label()
|
| 21 |
-
examples = ['dog.jpg']
|
| 22 |
|
| 23 |
-
# Cell
|
| 24 |
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
| 25 |
-
intf.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from fastai.vision.all import *
|
| 2 |
import gradio as gr
|
|
|
|
| 3 |
|
| 4 |
+
def is_cat(x): return x[0].isupper()
|
| 5 |
+
|
| 6 |
learn = load_learner('model.pkl')
|
| 7 |
|
| 8 |
+
categories = ('Dog', 'Cat')
|
|
|
|
| 9 |
|
| 10 |
def classify_image(img):
|
| 11 |
pred,idx,probs = learn.predict(img)
|
| 12 |
return dict(zip(categories, map(float,probs)))
|
| 13 |
|
|
|
|
| 14 |
image = gr.inputs.Image(shape=(192, 192))
|
| 15 |
label = gr.outputs.Label()
|
| 16 |
+
examples = ['dog.jpg', 'cat.jpg', 'dunno.jpg']
|
| 17 |
|
|
|
|
| 18 |
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
| 19 |
+
intf.launch(inline=False)
|