Skip to content
forked from zhoubolei/CAM

Class Activation Mapping with Caffe using the Python wrapper pycaffe instead of matlab.

Notifications You must be signed in to change notification settings

gcucurull/CAM-Python

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Class Activation Mapping for Python

I have written the files demo.m and generate_bbox.m in Python in order to be able to use the script without Matlab. In order to run it in Python one just need to run

python py_demo.py

and

python py_generate_bbox.py

Sample code for the Class Activation Mapping

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:

Usage Instructions:

  • Install caffe, compile the matcaffe (matlab wrapper for caffe), and make sure you could run the prediction example code classification.m.
  • Clone the code from Github:
git clone https://github.com/metalbubble/CAM.git
cd CAM
  • Download the pretrained network
sh models/download.sh
  • Run the demo code to generate the heatmap: in matlab terminal,
demo
  • Run the demo code to generate bounding boxes from the heatmap: in matlab terminal,
generate_bbox

The demo video of what the CNN is looking is here. The reimplementation in tensorflow is here.

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.

About

Class Activation Mapping with Caffe using the Python wrapper pycaffe instead of matlab.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • MATLAB 45.8%
  • C++ 27.7%
  • Python 15.3%
  • C 10.3%
  • Other 0.9%