haofanwang / Score-CAM

Official implementation of Score-CAM in PyTorch
MIT License
399 stars 66 forks source link

If value of score_saliency_map is all nagative, how can i solve this? #5

Closed DJ-Maeng closed 3 years ago

DJ-Maeng commented 3 years ago

Hi, I'm interested in Score-CAM and I'm using it.

I use Score-CAM in pytorch model vgg16_bn and ImageNet validation image. Most of the values on the activation map have negative values.

So score_saliency_map has all negative values and F.relu return all zeros.

My question is

(1) If score_sliency_map have all negative values, I cannot use Score-CAM?

(2) Is there any solution?

haofanwang commented 3 years ago

@DJ-Maeng Thanks for your interest.

I didn't meet this problem before where most values on activation maps are negative, but here are some suggestions. (1) ReLU operation is not necessary, we just follow the setting as previous works to make the saliency map better in visual. You can remove it in your case. (2) Instead of linearly combine the scores/weights with the original activation maps, you can use the normalized activations with values in [0,1].

Please let me know whether these help. If you have further questions, feel free to discuss here.

DJ-Maeng commented 3 years ago

Thank you for your answer. Your answer was very helpful.

I will apply the answers to the question (2).

I was able to see that the activation maps were created properly in VGG16, but I could see that all values of the score_salency_map were negative values in VGG16_bn.

I use pytorch.models.vgg16_bn(batch normalization) and ILSVRC2012_img_val. I did the same as possible as the environment I experimented with in your paper.

I may have made a mistake, but I'll show you the image number and the result of the ScoreCAM_map.

ILSVRC2012_val_00003014.JPEG image

ILSVRC2012_val_00000293 ILSVRC2012_val_00002138

I haven't checked all the images, but the images I checked are the same as the three above.

haofanwang commented 3 years ago

I didn't test VGG_BN in the paper. To reproduce the result, try VGG16.

This may be caused by the BN operation after the last convolution layer. Thus, another suggestion is that you can hook the activation map before the BN layer.

DJ-Maeng commented 3 years ago

Oh I`m really thank you for your answer. I apply your suggestion. I think Score-CAM is very good idea