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
9.79k stars 1.52k forks source link

Pytorch YoloV5 model with GradCAM #463

Open ugroznc opened 8 months ago

ugroznc commented 8 months ago

I have trained an xlarge YoloV5 model using DIOR Dataset with Ultralytics. I can not use it with GradCAM. Is there any way that I can use my model with GradCAM?

Besr Regards.

jS5t3r commented 2 months ago

U can take any layer of the model. Usually, the last block is used for best results. It can be tricky and you might need to add an Identity layer to the pre-trained model, which is useful to get the gradients... applying norm1 or norm2 would help, too.