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.32k stars 1.54k forks source link

Problem EigenCAM for YOLO5 #402

Open MattBlue92 opened 1 year ago

MattBlue92 commented 1 year ago

Hi there! Hello everyone! I am trying to use grad-cam with Yolov5. I've done some experimenting and if I run the notebook using the default code found at https://jacobgil.github.io/pytorch-gradcam-book/EigenCAM%20for%20YOLO5.html everything works. The problem comes when I try to load a yolov5 custum model and with custom weights, basically if I run these 2 instructions:

cam = EigenCAM(model, target_layers, use_cuda=False) grayscale_cam = cam(tensor)[0, :, :]

the python interpreter tells me AttributeError: 'tuple' object has no attribute 'cpu'

Someone can help me?

JunKaiLiao commented 1 year ago

I got the same problem. Have you fix this ?

ZhangHaoyou commented 5 months ago

I also encountered this problem. Do you find a solution or alternative?

ZhangHaoyou commented 5 months ago

I have found a solution to this problem. We have to modify the pytorch_grad_cam original scripts.