Simple way to leverage the class-specific activation of convolutional layers in PyTorch.
- Python 3.6 (or more recent)
- pip
You can install the package using pypi as follows:
pip install torchcam
or using conda:
conda install -c frgfm torchcam
You can find a detailed example below to retrieve the CAM of a specific class on a resnet architecture.
python scripts/cam_example.py --model resnet50 --class-idx 232
The full package documentation is available here for detailed specifications. The documentation was built with Sphinx using a theme provided by Read the Docs.
Please refer to CONTRIBUTING
if you wish to contribute to this project.
This project is developed and maintained by the repo owner, but the implementation was based on the following precious papers:
- Learning Deep Features for Discriminative Localization: the original CAM paper
- Grad-CAM: GradCAM paper, generalizing CAM to models without global average pooling.
- Grad-CAM++: improvement of GradCAM++ for more accurate pixel-level contribution to the activation.
- Smooth Grad-CAM++: SmoothGrad mechanism coupled with GradCAM.
- Score-CAM: score-weighting of class activation for better interpretability.
- SS-CAM: SmoothGrad mechanism coupled with Score-CAM.
- IS-CAM: integration-based variant of Score-CAM.
Distributed under the MIT License. See LICENSE
for more information.