Home

Awesome

Sample code for the Class Activation Mapping

NEW: PyTorch Demo code

    python pytorch_CAM.py

You also could take a look at the unified PlacesCNN scene prediction code to see how the CAM along with scene categories, scene attributes are predicted. It has been used in the PlacesCNN scene recognition demo.

We propose a simple technique to expose the implicit attention of Convolutional Neural Networks on the image. It highlights the most informative image regions relevant to the predicted class. You could get attention-based model instantly by tweaking your own CNN a little bit more. The paper is published at CVPR'16.

The framework of the Class Activation Mapping is as below: Framework

Some predicted class activation maps are: Results

Pre-trained models in Caffe:

Usage Instructions:

git clone https://github.com/metalbubble/CAM.git
cd CAM
sh models/download.sh
demo
generate_bbox

The demo video of what the CNN is looking is here. The reimplementation in tensorflow is here. The pycaffe wrapper of CAM is reimplemented at here.

ILSVRC evaluation

Reference:

@inproceedings{zhou2016cvpr,
    author    = {Zhou, Bolei and Khosla, Aditya and Lapedriza, Agata and Oliva, Aude and Torralba, Antonio},
    title     = {Learning Deep Features for Discriminative Localization},
    booktitle = {Computer Vision and Pattern Recognition},
    year      = {2016}
}

License:

The pre-trained models and the CAM technique are released for unrestricted use.

Contact Bolei Zhou if you have questions.