jacobgil / pytorch-grad-cam

Advanced AI Explainability for computer vision. Support for CNNs, Vision Transformers, Classification, Object detection, Segmentation, Image similarity and more.
https://jacobgil.github.io/pytorch-gradcam-book
MIT License
10.06k stars 1.52k forks source link

The color of the background #270

Closed Dongjiuqing closed 2 years ago

Dongjiuqing commented 2 years ago

Thanks for your work. I use the code of [EigenCAM for YOLO5.ipynb] I test one image by using your example. But the color of the feature map for the background is red. In your example, the background should be blue. the result looks as follows: I want to know the reason

result
Dongjiuqing commented 2 years ago

Actually, I fix this issue by set the param‘use_rgb=True’ -> 'use_rgb=False'

cam_image = show_cam_on_image(img, grayscale_cam, use_rgb=False)

But I still have a question. Why the result didn't focus on the target. Generally speaking, the red area should cover the bounding-box area. But the color of the target area is the same as the background area. Is the model or the code causing the problem?

result
jacobgil commented 2 years ago

Hi, It looks like the dominant features here are from the the yellow-pepper, and this is what Eigen-CAM returns. This is a drawback of EigenCAM since it returns only the first principle vector.

ivsim01 commented 12 months ago

Hi, @jacobgil ! Thanks for your work! I'm also working with YOLOv5, EigenCAM and a custom trained model.

I am dealing with a similar application as the yellow pepper shown above. The EigenCAM prior re-normalization shows as well stronger activated pixels outside the predicted bounding box than within, but its confident score still achieves more than 90%. I was wondering how can both situations occur in parallel? Is this a flaw of the EigenCAM algorithm and thus requires the re-normalization? For example on the prior-normalization yellow-pepper image, some pixels on the hand are highly activated, how could we explain that with respect to the target?

If you could me explain a little bit more, it would be great!