Skip to content

Class Activation Mapping written in PyTorch.

Notifications You must be signed in to change notification settings

Kenneth-X/pytorch-CAM

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pytorch-CAM

This repository is an unofficial version of Class Activation Mapping written in PyTorch.

Class Activation Mapping (CAM)

Paper and Archiecture: Learning Deep Features for Discriminative Localization

Paper Author Implementation: metalbubble/CAM

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.



Code Description

Usage: python3 main.py

Network: Inception V3

Data: Kaggle dogs vs. cats

  • Download the 'test1.zip' and 'train.zip' files and upzip them.
  • Divde the total dataset into train group and test group. As you do that, images must be arranged in this way:
    kaggle/train/cat/*.jpg
    kaggle/test/cat/*.jpg
    

Checkpoint

  • Checkpoint will be created in the checkpoint folder every ten epoch.
  • By setting RESUME = #, you can resume from checkpoint/#.pt.

About

Class Activation Mapping written in PyTorch.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%