• Stars
    star
    1,839
  • Rank 25,243 (Top 0.5 %)
  • Language
    MATLAB
  • License
    MIT License
  • Created over 8 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Class Activation Mapping

Sample code for the Class Activation Mapping

NEW: PyTorch Demo code

  • The popular networks such as ResNet, DenseNet, SqueezeNet, Inception already have global average pooling at the end, so you could generate the heatmap directly without even modifying the network architecture. Here is a sample script to generate CAM for the pretrained networks.
    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:

  • 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. 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.

More Repositories

1

introRL

Intro to Reinforcement Learning (εΌΊεŒ–ε­¦δΉ ηΊ²θ¦οΌ‰
3,195
star
2

bolei_awesome_posters

CVPR and NeurIPS poster examples and templates. May we have in-person poster session soon!
1,362
star
3

TRN-pytorch

Temporal Relation Networks
Python
787
star
4

moments_models

The pretrained models trained on Moments in Time Dataset
Python
355
star
5

cnnvisualizer

Visualizer for Deep Neural Networks
C
292
star
6

VQAbaseline

Simple Baseline for Visual Question Answering
Lua
186
star
7

awesome-generative-modeling

Bolei's archive on generative modeling
157
star
8

places_devkit

Development kit for the data of the Places365-Standard and Places365-Challenge
MATLAB
118
star
9

GoSpark

Go
77
star
10

TRN-deprecate

Code for Temporal Relation Networks
24
star
11

awesome-neural-planner

personal paper reading on neural motion planner and controller
24
star
12

collectiveness

The source codes in the CVPR2013 Paper: Measuring Crowd Collectiveness
MATLAB
24
star
13

introGM

Tutorial on Generative Modeling: Interacting with Deep Generative Models for Content Creation
20
star
14

GKLT

The binary code of generalized KLT tracker
C
19
star
15

CohFilter

MATLAB
10
star
16

pytorch_imagecaptioning

Jupyter Notebook
9
star
17

moments_recognition

Python
7
star
18

cuhkcourse_multimedia

Code examples for the IERG4190/IEMS5707 course
Jupyter Notebook
6
star
19

RF_topic

C++
5
star
20

feature_invertion_torch

Lua
4
star
21

cvpr19_textureobjectscene

webpage for the CVPR'19 Tutorial on Textures, Objects, and Scenes
HTML
3
star
22

ierg3050simulation

Example code for the IERG3050 Simulation and Statistical Analysis
Jupyter Notebook
3
star
23

Hello-World

first blood on Github
Objective-C
1
star
24

deepmodel

course project for Advance in Computer Vision
Python
1
star
25

coursera

codes for online courses
Python
1
star
26

deepfeature

The toolkit to evaluate the deep features for visual recognition
1
star