MadhurGarg commited on
Commit
edabf79
·
1 Parent(s): 5499ef7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -56,8 +56,8 @@ def image_classifier(input_image, top_classes=3, show_cam=True, target_layers=[2
56
  confidences = {classes[i]: float(o[i]) for i in range(10)}
57
  _, label = torch.max(output, 1)
58
 
59
- #confidences.sort(key=lambda x: x[1], reverse=True)
60
- #confidences = OrderedDict(confidences[:top_classes])
61
  #label = torch.argmax(output).item()
62
 
63
  outputs = list()
@@ -69,7 +69,7 @@ def image_classifier(input_image, top_classes=3, show_cam=True, target_layers=[2
69
 
70
  return outputs, confidences
71
 
72
- examples = [["examples/cat.jpg", 0.5, -1], ["examples/dog.jpg", 0.5, -1]]
73
  demo1 = gr.Interface(
74
  fn=image_classifier,
75
  inputs=[
@@ -82,7 +82,7 @@ demo1 = gr.Interface(
82
  gr.Slider(0, 1, value=0.5, label="Transparency", step=0.1,
83
  info="Set Transparency of CAMs")
84
  ],
85
- outputs=[gr.Gallery(label="Output Images", columns=2, rows=2), gr.Label(label='Top Classes',num_top_classes=3)],
86
  examples=examples
87
  )
88
 
 
56
  confidences = {classes[i]: float(o[i]) for i in range(10)}
57
  _, label = torch.max(output, 1)
58
 
59
+ confidences.sort(key=lambda x: x[1], reverse=True)
60
+ confidences = OrderedDict(confidences[:top_classes])
61
  #label = torch.argmax(output).item()
62
 
63
  outputs = list()
 
69
 
70
  return outputs, confidences
71
 
72
+ examples = [["examples/cat.jpg", 3, True,["-2","-1"],0.5], ["examples/dog.jpg", 3, True,["-2","-1"],0.5]]
73
  demo1 = gr.Interface(
74
  fn=image_classifier,
75
  inputs=[
 
82
  gr.Slider(0, 1, value=0.5, label="Transparency", step=0.1,
83
  info="Set Transparency of CAMs")
84
  ],
85
+ outputs=[gr.Gallery(label="Output Images", columns=2, rows=2), gr.Label(label='Top Classes')],
86
  examples=examples
87
  )
88