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.65k stars 1.56k forks source link

TypeError: __init__() got an unexpected keyword argument 'target_layer' #176

Closed prinzROSE closed 2 years ago

prinzROSE commented 2 years ago

Exception ignored in: <bound method BaseCAM.del of <pytorch_grad_cam.grad_cam.GradCAM object at 0x7fc75494ac88>> Traceback (most recent call last): File "/data/caiyong.wang/bin/anaconda3/envs/gu1/lib/python3.6/site-packages/pytorch_grad_cam/base_cam.py", line 192, in del self.activations_and_grads.release() AttributeError: 'GradCAM' object has no attribute 'activations_and_grads' Traceback (most recent call last): File "/data1/caiyong.wang/song/original_DeepCrack/codes/heat map.py", line 56, in cam = GradCAM(model=model, target_layer=target_layer, use_cuda=False) TypeError: init() got an unexpected keyword argument 'target_layer'

hi,I have a problem. please u help me!thank u

wxr5899 commented 2 years ago

I guess you just spell the attribute wrong, it should be target_layers not target_layer. This will lead to the defeat of the initialization of attribute activations_and_grads. Hope this can help you!

jacobgil commented 2 years ago

Yes, it should be target_layers (and it should be a list).

xzk18360175140 commented 2 years ago

(py310) D:\cmi_china\agile_innovation\agile_innovation\backend>flask run

wxr5899 commented 2 years ago

这是来自QQ邮箱的假期自动回复邮件。   您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。