Spaces:
Sleeping
Sleeping
embracethesock
commited on
Commit
·
d6d8b22
1
Parent(s):
f273ad4
working
Browse files- app.py +16 -9
- cat_ex.jpg +0 -0
- dog_ex.jpg +0 -0
app.py
CHANGED
@@ -1,16 +1,23 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
|
3 |
-
|
4 |
|
5 |
-
|
6 |
-
|
|
|
|
|
7 |
pred,pred_idx,probs = learn.predict(img)
|
8 |
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
inputs=gr.inputs.Image(shape=(512, 512)),
|
13 |
-
outputs=gr.outputs.Label(num_top_classes=3)
|
14 |
-
).launch(share=True)
|
15 |
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from fastai.vision.all import *
|
3 |
+
import skimage
|
4 |
|
5 |
+
def is_cat(x): return x[0].isupper()
|
6 |
|
7 |
+
learn = load_learner('dog_or_cat.pkl')
|
8 |
+
labels = learn.dls.vocab
|
9 |
+
def predict(img):
|
10 |
+
img = PILImage.create(img)
|
11 |
pred,pred_idx,probs = learn.predict(img)
|
12 |
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
13 |
|
14 |
+
title = "Is it a Cat?"
|
15 |
+
examples = ['cat_ex.jpg', 'dog_ex.jpg']
|
|
|
|
|
|
|
16 |
|
17 |
+
gr.Interface(
|
18 |
+
fn=predict,
|
19 |
+
inputs=gr.components.Image(height=512, width=512),
|
20 |
+
outputs=gr.components.Label(),
|
21 |
+
title=title,
|
22 |
+
examples=examples,
|
23 |
+
).launch()
|
cat_ex.jpg
ADDED
dog_ex.jpg
ADDED