yizt / Grad-CAM.pytorch

pytorch实现Grad-CAM和Grad-CAM++,可以可视化任意分类网络的Class Activation Map (CAM)图,包括自定义的网络;同时也实现了目标检测faster r-cnn和retinanet两个网络的CAM图;欢迎试用、关注并反馈问题...

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

a little bug in detection/demo.py/gen_cam()

liaorongfan opened this issue · comments

commented
def gen_cam(image, mask):
    heatmap = cv2.applyColorMap(np.uint8(255 * mask), cv2.COLORMAP_JET)
    # heatmap = np.float32(heatmap) / 255  # little bug here
    heatmap = np.float32(heatmap)
    heatmap = heatmap[..., ::-1]  # gbr to rgb
    cam = heatmap + np.float32(image)
    return norm_image(cam), heatmap

For variable "heatmap" there is no need to divide by 255.

@liaorongfan 感谢您的反馈,image的值范围是01,heatmap也缩放到01之间,两者相加时在同一数值范围