pip install pytorch-gradcam
- 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.
Use your own model and layer:
model = MyModel()
target_layer = model.my_submodule
gradcam = GradCAM(model, target_layer)
[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