Implementation based on the paper by Selvaraju et al.
Pytorch implementation for Grad-CAM, using pytorch hooks, which enable us to access the individual gradients during backpropagation. The GradCAM implementation can look at the gradients flowing through any specified CNN layer in the model and compute a class activation mapping. By choosing the label from which we backpropagate from, it is possible to observe the regions of interest pertinent to the label.
The implementation also includes extensions of GradCAM such as:
- Class Discriminative GradCAM
- Guided GradCAM
- Counterfactual Activation Map
GradCam.py
contains the main implementation of the GradCAM and its extensions. The jupyter notebooks use modules imported from GradCam.py
, and demonstrate their usage.
- Base GradCAM
- Class Discriminative GradCAM
- Counterfactual Activation Mapping
- Guided GradCAM
- GradCAM for VQA