Update app.py
Browse files
app.py
CHANGED
@@ -17,12 +17,23 @@ categories = ('Dog', 'Cat')
|
|
17 |
|
18 |
def classify_image(img):
|
19 |
pred,idx,probs = learn.predict(img)
|
20 |
-
|
|
|
|
|
|
|
|
|
21 |
|
22 |
# Cell
|
23 |
image = gr.inputs.Image(shape=(192, 192))
|
24 |
-
label = gr.outputs.Label()
|
25 |
-
examples = ['dog.jpg', 'cat.jpg', 'dunno.jpg']
|
26 |
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
intf.launch(inline=False)
|
|
|
17 |
|
18 |
def classify_image(img):
|
19 |
pred,idx,probs = learn.predict(img)
|
20 |
+
if probs[0]>probs[1]:
|
21 |
+
pred_class = 'This is Dog'
|
22 |
+
else:
|
23 |
+
pred_class = 'This is Cat'
|
24 |
+
return pred_class, dict(zip(categories, map(float,probs)))
|
25 |
|
26 |
# Cell
|
27 |
image = gr.inputs.Image(shape=(192, 192))
|
|
|
|
|
28 |
|
29 |
+
set_label = gr.outputs.Textbox(label="Predicted Class")
|
30 |
+
|
31 |
+
set_prob = gr.outputs.Label(num_top_classes=2, label="Predicted Probability Per Class")
|
32 |
+
examples = ['test1.jpg', 'test2.jpg', 'test3.jpeg', 'test4.jpeg', 'test5.jpeg', 'test6.jpeg', 'test7.jpeg', 'test8.jpeg', 'test9.jpeg', 'test10.jpeg']
|
33 |
+
|
34 |
+
intf = gr.Interface(fn=classify_image,
|
35 |
+
inputs=image,
|
36 |
+
outputs=[set_label, set_prob],
|
37 |
+
examples_per_page = 2,
|
38 |
+
examples=examples)
|
39 |
intf.launch(inline=False)
|