Spaces:
Sleeping
Sleeping
Chong-U Lim
commited on
Commit
Β·
7aaf1ee
1
Parent(s):
8895221
Update 5
Browse files- .ipynb_checkpoints/app-checkpoint.py +22 -0
- cat.jpeg β cat.jpg +0 -0
- dog.jpeg β dog.jpg +0 -0
- dunno.jpeg β dunno.jpg +0 -0
.ipynb_checkpoints/app-checkpoint.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
__all__ = ['is_cat', 'learn', 'classify_image', 'categories', 'image', 'label', 'examples', 'intf']
|
2 |
+
|
3 |
+
from fastai.vision.all import load_learner
|
4 |
+
import gradio as gr
|
5 |
+
|
6 |
+
def is_cat(x): return x[0].isupper()
|
7 |
+
|
8 |
+
learn = load_learner('model.pkl')
|
9 |
+
|
10 |
+
categories = ('Dog', 'Cat')
|
11 |
+
|
12 |
+
def classify_image(img):
|
13 |
+
pred, idx, probs = learn.predict(img)
|
14 |
+
return dict(zip(categories, map(float, probs)))
|
15 |
+
|
16 |
+
image = gr.components.Image(height=192, width=192)
|
17 |
+
label = gr.components.Label()
|
18 |
+
|
19 |
+
examples = ['dog.jpg', 'cat.jpg', 'dunno.jpg']
|
20 |
+
|
21 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
22 |
+
intf.launch(inline=False)
|
cat.jpeg β cat.jpg
RENAMED
File without changes
|
dog.jpeg β dog.jpg
RENAMED
File without changes
|
dunno.jpeg β dunno.jpg
RENAMED
File without changes
|