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