You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.
conv_out should be multiplied by the average of the conv_out_grad in the reference paper. but conv_out be multiplied by the average of the imggrad in your gradcam.py.
What have you tried to solve it?
def get_cam(conv_out_grad, conv_out):
"""Compute CAM. Refer section 3 of https://arxiv.org/abs/1610.02391 for details"""
weights = np.mean(conv_out_grad, axis=(1, 2))
cam = np.ones(conv_out.shape[1:], dtype=np.float32)
for i, w in enumerate(weights):
cam += w * conv_out[i, :, :]
#=============================
# Put this line of code below
#cam = cv2.resize(cam, (imggrad.shape[1], imggrad.shape[2]))
#=============================
@whl33886 The issue has been fixed now. @sandeep-krishnamurthy Could you please close the issue as it has been fixed. @whl33886 Please feel free to reopen in case closed in error.
Error Message:
conv_out should be multiplied by the average of the conv_out_grad in the reference paper. but conv_out be multiplied by the average of the imggrad in your gradcam.py.
What have you tried to solve it?
def get_cam(conv_out_grad, conv_out):
"""Compute CAM. Refer section 3 of https://arxiv.org/abs/1610.02391 for details"""
weights = np.mean(conv_out_grad, axis=(1, 2))
cam = np.ones(conv_out.shape[1:], dtype=np.float32)
for i, w in enumerate(weights):
cam += w * conv_out[i, :, :]
#=============================
# Put this line of code below
#cam = cv2.resize(cam, (imggrad.shape[1], imggrad.shape[2]))
#=============================
def visualize(net, preprocessed_img, orig_img, conv_layer_name):
# Returns grad-cam heatmap, guided grad-cam, guided grad-cam saliency
imggrad = get_image_grad(net, preprocessed_img)
conv_out, conv_out_grad = get_conv_out_grad(net, preprocessed_img, conv_layer_name=conv_layer_name)
#===========================
#imggrad replaced by conv_out_grad
cam = get_cam(conv_out_grad, conv_out)
#Add this line
cam = cv2.resize(cam, (imggrad.shape[1], imggrad.shape[2]))
#===================================
The text was updated successfully, but these errors were encountered: