Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -45,20 +45,18 @@ def inference(input_image):
|
|
45 |
#with open("dog_cat.txt", "r") as f:
|
46 |
#categories = [s.strip() for s in f.readlines()]
|
47 |
#with open("dog_cat.txt", "r") as f:
|
48 |
-
categories = []
|
49 |
-
categories.append("cat")
|
50 |
-
categories.append("dog")
|
51 |
|
52 |
#categories = [s.strip() for s in f.readlines()]
|
53 |
# Show top categories per image
|
54 |
-
|
55 |
result = {}
|
56 |
-
for i in range(
|
57 |
-
result[categories[
|
58 |
return result
|
59 |
|
60 |
inputs = gr.inputs.Image(type='pil')
|
61 |
-
outputs = gr.outputs.Label(type="confidences",num_top_classes=
|
62 |
|
63 |
title = "GHOSTNET"
|
64 |
description = "Gradio demo for GHOSTNET, Efficient networks by generating more features from cheap operations. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below."
|
|
|
45 |
#with open("dog_cat.txt", "r") as f:
|
46 |
#categories = [s.strip() for s in f.readlines()]
|
47 |
#with open("dog_cat.txt", "r") as f:
|
48 |
+
categories = ["cat","dog"]
|
|
|
|
|
49 |
|
50 |
#categories = [s.strip() for s in f.readlines()]
|
51 |
# Show top categories per image
|
52 |
+
top1_prob, top1_catid = torch.topk(probabilities, 1)
|
53 |
result = {}
|
54 |
+
for i in range(top1_prob.size(0)):
|
55 |
+
result[categories[top1_catid[i]]] = top1_prob[i].item()
|
56 |
return result
|
57 |
|
58 |
inputs = gr.inputs.Image(type='pil')
|
59 |
+
outputs = gr.outputs.Label(type="confidences",num_top_classes=1)
|
60 |
|
61 |
title = "GHOSTNET"
|
62 |
description = "Gradio demo for GHOSTNET, Efficient networks by generating more features from cheap operations. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below."
|