Giter VIP home page Giter VIP logo

tensorflow-class-activation-mapping's Introduction

Learning Deep Features for Discriminative Localization

Tensorflow Implementation

https://arxiv.org/abs/1512.04150

How to use it?

# For Python 3. Should also work for Python2 :)
git clone [email protected]:philipperemy/tensorflow-class-activation-mapping.git
cd tensorflow-class-activation-mapping
pip3 install -r requirements.txt
mkdir /tmp/img
tar xvzf data/mnist_cluttered.tar.gz -C /tmp/img
python3 mnist.py # The heatmaps are available in out/

Abstract

In this work, we revisit the global average pooling layer and shed light on how it explicitly enables the convolutional neural network to have remarkable localization ability despite being trained on image-level labels. While this technique was previously proposed as a means for regularizing training, we find that it actually builds a generic localizable deep representation that can be applied to a variety of tasks. Despite the apparent simplicity of global average pooling, we are able to achieve 37.1% top-5 error for object localization on ILSVRC 2014, which is remarkably close to the 34.2% top-5 error achieved by a fully supervised CNN approach. We demonstrate that our network is able to localize the discriminative image regions on a variety of tasks despite not being trained for them.

Class Activation Mapping and Class-specific Saliency Map

We propose a technique for generating class activation maps using the global average pooling (GAP) in CNNs. A class activation map for a particular category indicates the discriminative image regions used by the CNN to identify that category. The procedure for generating these maps is illustrated as follows:



Class activation maps could be used to intepret the prediction decision made by the CNN. The left image below shows the class activation map of top 5 predictions respectively, you can see that the CNN is triggered by different semantic regions of the image for different predictions. The right image below shows the CNN learns to localize the common visual patterns for the same object class.



MNIST cluttered dataset with LeNet

LeNet was used on the MNIST cluttered dataset, provided by DeepMind. We removed the last fully connected layers and replaced them with the Class Activation Map. The accuracy was 97% after 50 epochs (Final accuracy was 97.6%). Here is an example of an input image (9):



The output of the Class Activation Map is provided below, at different steps:



The overall accuracy on the testing set, per step:



CALTECH256 dataset with AlexNet pretrained with ImageNet

Coming soon!

tensorflow-class-activation-mapping's People

Contributors

philipperemy avatar ydup avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tensorflow-class-activation-mapping's Issues

Raise assertion error

while running (python mnist.py) raise an error

Traceback (most recent call last):
File "mnist.py", line 9, in
[images_train, labels_train], [images_test, labels_test] = read_dataset(dataset_percentage)
File "H:\tensorflow-class-activation-mapping-master\utils.py", line 50, in read_dataset
assert n == len(labels)
AssertionError

How to implement a test

Hi,

I successfully run the codes, but am confused about how to get result.png? Is there any python program to run?

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.