This repository contains a simple PyTorch implementation of GradCAM [1], and GradCAM++ [2] for example PET image [3].
The following repository re-uses the code by 1Konny from: https://github.com/1Konny/gradcam_plus_plus-pytorch. It was the only simple working example on the use of GradCAM I was able to find on the Internet. I decided to create a new repository (copy it) instead of forking the existing one because this way it is easier to manage features such as repository title, issues, etc.
My modification is that I fixed one error, and I used a PET image from this article [3] this example. Additionally, I made some changes to the README for better readability.
- alexnet
- vgg
- resnet
- densenet
- squeezenet
Please refer to example.ipynb
for general usage and refer to documentations of each layer-finding functions
in utils.py
if you want to know how to set target_layer_name
properly.
[1] Grad-CAM: Visual Explanations from Deep Networks via Gradient-based Localization, Selvaraju et al, ICCV, 2017
[2] Grad-CAM++: Generalized Gradient-based Visual Explanations for Deep Convolutional Networks, Chattopadhyay et al, WACV, 2018
[3] Prieto-Vargas, V., Bautista-Prez-Gavilan, A., Lucio-Báez, O.E., Sierra-Poblete, S. and Gurrola-Luna, H., 2022. PET-Myocardial Perfusion Imaging in the Assessment of Coronary Artery Disease: the basics. Clin Res Trials, 8.