MadhurGarg commited on
Commit
fe2e2e1
·
1 Parent(s): 8d6429d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -33,7 +33,7 @@ inv_normalize = T.Normalize(
33
  mean=[-0.50/0.23, -0.50/0.23, -0.50/0.23],
34
  std=[1/0.23, 1/0.23, 1/0.23])
35
 
36
- grad_cams = [GradCAM(model=model, target_layers=[model.convblock3[i]], use_cuda=False) for i in range(4)]
37
 
38
  def get_gradcam_image(input_tensor, label, target_layer):
39
  grad_cam = grad_cams[target_layer]
@@ -44,6 +44,7 @@ def get_gradcam_image(input_tensor, label, target_layer):
44
 
45
 
46
  def image_classifier(input_image, top_classes=3, show_cam=True, target_layers=[2, 3], transparency=0.5):
 
47
  orig_image = input_image
48
  input_image = transform(input_image)
49
 
@@ -77,7 +78,7 @@ demo1 = gr.Interface(
77
  gr.Slider(1, 10, value=3, step=1, label="Top Classes",
78
  info="How many top classes do you want to view?"),
79
  gr.Checkbox(label="Enable GradCAM", value=True, info="Do you want to see Class Activation Maps?"),
80
- gr.CheckboxGroup(["-4", "-3", "-2", "-1"], value=["-2", "-1"], label="Network Layers", type='index',
81
  info="Which layer CAMs do you want to visualize?",),
82
  gr.Slider(0, 1, value=0.5, label="Transparency", step=0.1,
83
  info="Set Transparency of CAMs")
 
33
  mean=[-0.50/0.23, -0.50/0.23, -0.50/0.23],
34
  std=[1/0.23, 1/0.23, 1/0.23])
35
 
36
+ grad_cams = [GradCAM(model=model, target_layers=[model.convblock3[i]], use_cuda=False) for i in range(5)]
37
 
38
  def get_gradcam_image(input_tensor, label, target_layer):
39
  grad_cam = grad_cams[target_layer]
 
44
 
45
 
46
  def image_classifier(input_image, top_classes=3, show_cam=True, target_layers=[2, 3], transparency=0.5):
47
+ global top_classes_g
48
  orig_image = input_image
49
  input_image = transform(input_image)
50
 
 
78
  gr.Slider(1, 10, value=3, step=1, label="Top Classes",
79
  info="How many top classes do you want to view?"),
80
  gr.Checkbox(label="Enable GradCAM", value=True, info="Do you want to see Class Activation Maps?"),
81
+ gr.CheckboxGroup(["-5","-4", "-3", "-2", "-1"], value=["-2", "-1"], label="Network Layers", type='index',
82
  info="Which layer CAMs do you want to visualize?",),
83
  gr.Slider(0, 1, value=0.5, label="Transparency", step=0.1,
84
  info="Set Transparency of CAMs")