utkuozbulak / pytorch-cnn-visualizations

Pytorch implementation of convolutional neural network visualization techniques
MIT License
7.85k stars 1.49k forks source link

CAM heatmap should be in [0, 1] #38

Closed xuyuan closed 5 years ago

xuyuan commented 5 years ago

https://github.com/utkuozbulak/pytorch-cnn-visualizations/blob/ad79687d926b83e109e3e6bf559d867fc5e950f8/src/gradcam.py#L88

add cam = cam / 255 ?

utkuozbulak commented 5 years ago

Hello,

The line you are referring to is there to resize the image properly. I would suggest reading the comments below that line. Cam heatmap was indeed in [0,1] (check line 86) and scaled to [0,255] so that we are able to export it as an image.

xuyuan commented 5 years ago

however the save_image will scale it up 255 again: https://github.com/utkuozbulak/pytorch-cnn-visualizations/blob/ad79687d926b83e109e3e6bf559d867fc5e950f8/src/misc_functions.py#L118

The current master code doesn't produce the same heatmap as REAMDE

utkuozbulak commented 5 years ago

Oh, I thought I tested those :disappointed:

I will check it today! Thanks for letting me know.

utkuozbulak commented 5 years ago

Just committed a bandaid fix for image saving. I will streamline image saving soon. It is currently a mess.