Spaces:
Runtime error
Runtime error
Commit ·
2b21b5a
1
Parent(s): 4885069
fixed requirements
Browse files
app.py
CHANGED
|
@@ -1,29 +1,30 @@
|
|
|
|
|
| 1 |
|
| 2 |
# %% auto 0
|
| 3 |
__all__ = ['learn', 'categories', 'image', 'label', 'examples', 'intf', 'is_cat', 'classify_image']
|
| 4 |
|
| 5 |
-
# %% notebook.ipynb
|
| 6 |
from fastai.vision.all import *
|
| 7 |
import gradio as gr
|
| 8 |
|
| 9 |
def is_cat(x): return x(0).isupper()
|
| 10 |
|
| 11 |
|
| 12 |
-
# %% notebook.ipynb
|
| 13 |
learn = load_learner('model.pkl')
|
| 14 |
|
| 15 |
|
| 16 |
-
# %% notebook.ipynb
|
| 17 |
categories = ('dog' , 'cat')
|
| 18 |
|
| 19 |
def classify_image(img):
|
| 20 |
pred, idx, probs= learn.predict(img)
|
| 21 |
return dict(zip(categories, map(float,probs)))
|
| 22 |
|
| 23 |
-
# %% notebook.ipynb
|
| 24 |
-
image = gr.Image(192,192)
|
| 25 |
label = gr.Label()
|
| 26 |
-
examples =
|
| 27 |
|
| 28 |
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
| 29 |
intf.launch(inline=False)
|
|
|
|
| 1 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: notebook.ipynb.
|
| 2 |
|
| 3 |
# %% auto 0
|
| 4 |
__all__ = ['learn', 'categories', 'image', 'label', 'examples', 'intf', 'is_cat', 'classify_image']
|
| 5 |
|
| 6 |
+
# %% notebook.ipynb 4
|
| 7 |
from fastai.vision.all import *
|
| 8 |
import gradio as gr
|
| 9 |
|
| 10 |
def is_cat(x): return x(0).isupper()
|
| 11 |
|
| 12 |
|
| 13 |
+
# %% notebook.ipynb 6
|
| 14 |
learn = load_learner('model.pkl')
|
| 15 |
|
| 16 |
|
| 17 |
+
# %% notebook.ipynb 9
|
| 18 |
categories = ('dog' , 'cat')
|
| 19 |
|
| 20 |
def classify_image(img):
|
| 21 |
pred, idx, probs= learn.predict(img)
|
| 22 |
return dict(zip(categories, map(float,probs)))
|
| 23 |
|
| 24 |
+
# %% notebook.ipynb 11
|
| 25 |
+
image = gr.Image(height=192, width= 192)
|
| 26 |
label = gr.Label()
|
| 27 |
+
examples = ['cat.jpg', 'dog.jpeg', 'dunno.jpg']
|
| 28 |
|
| 29 |
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
| 30 |
intf.launch(inline=False)
|