Spaces:
Runtime error
Runtime error
Amar Gill
commited on
Commit
•
fd3d42c
1
Parent(s):
02ba6f7
change prediction func return type
Browse files
app.py
CHANGED
@@ -11,11 +11,14 @@ learn = load_learner("model.pkl")
|
|
11 |
|
12 |
labels = learn.dls.vocab
|
13 |
|
|
|
|
|
14 |
|
15 |
def predict(img):
|
16 |
img = PILImage.create(img)
|
17 |
-
|
18 |
-
return
|
|
|
19 |
|
20 |
|
21 |
title = "Cat or Dog Classifier"
|
@@ -27,7 +30,7 @@ enable_queue = True
|
|
27 |
|
28 |
gr.Interface(
|
29 |
fn=predict,
|
30 |
-
inputs=gr.
|
31 |
outputs=gr.outputs.Label(num_top_classes=3),
|
32 |
title=title,
|
33 |
description=description,
|
|
|
11 |
|
12 |
labels = learn.dls.vocab
|
13 |
|
14 |
+
categories = ("Dog", "Cat")
|
15 |
+
|
16 |
|
17 |
def predict(img):
|
18 |
img = PILImage.create(img)
|
19 |
+
_, _, probs = learn.predict(img)
|
20 |
+
return dict(zip(categories, map(float, probs)))
|
21 |
+
# return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
22 |
|
23 |
|
24 |
title = "Cat or Dog Classifier"
|
|
|
30 |
|
31 |
gr.Interface(
|
32 |
fn=predict,
|
33 |
+
inputs=gr.components.Image(shape=(512, 512)),
|
34 |
outputs=gr.outputs.Label(num_top_classes=3),
|
35 |
title=title,
|
36 |
description=description,
|