@@ -52,7 +52,7 @@ def visualize_activations(model, module, img, max_acts = 64, save_path = None, d
5252 Plots the activations of a module recorded during a forward pass on an image
5353 """
5454 model .to (device )
55- # img_t = preprocess_image(img).to(device)
55+ img_t = preprocess_image (img ).to (device )
5656 acts = [0 ]
5757
5858 def hook_fn (self , input , output ):
@@ -87,7 +87,7 @@ def saliency_map(model, img, device = 'cuda', save_path = None):
8787
8888 model .eval ()
8989 model .to (device )
90- # img_t = preprocess_image(img).to(device)
90+ img_t = preprocess_image (img ).to (device )
9191 img_t .requires_grad = True
9292 img_t .retain_grad () #added this line
9393
@@ -120,7 +120,7 @@ def grad_cam(model, module, img, target_layer = ["4"], target_category= None, de
120120 grad_cam = GradCam (model = model , feature_module = module ,
121121 target_layer_names = target_layer , use_cuda = use_cuda )
122122
123- # img_t = preprocess_image(img).to(device)
123+ img_t = preprocess_image (img ).to (device )
124124
125125 grayscale_cam = grad_cam (img_t , target_category )
126126
@@ -167,7 +167,7 @@ def contrast_cam(model, module, img, target_layer = ["4"], target_category= None
167167 contrast_cam = ContrastCam (model = model , feature_module = module ,
168168 target_layer_names = target_layer , use_cuda = use_cuda )
169169
170- # img_t = preprocess_image(img).to(device)
170+ img_t = preprocess_image (img ).to (device )
171171
172172 assert (target_category != None ), "Please specify a target category"
173173 grayscale_cam = contrast_cam (img_t , target_category )
@@ -204,4 +204,4 @@ def contrast_cam(model, module, img, target_layer = ["4"], target_category= None
204204
205205 if save_path :
206206 fig1 .savefig (save_path )
207- return fig1
207+ return fig1
0 commit comments