/CAM

Primary LanguageJupyter NotebookMIT LicenseMIT

CAM(Class Activation Map)

This repository is an pytorch implementation of Learning Deep Features for Discriminative Localization.

It is modified from https://github.com/metalbubble/CAM/blob/master/pytorch_CAM.py.

All images are gathered from https://www.kaggle.com/c/dogs-vs-cats.

Requirements

  • python 3.6
  • torch 1.2
  • torchvision 0.5
  • numpy
  • matpotlib

Usage

To get CAM of images, you have to use a model which consist of [avg-pool, fc] as last 2-layers.

from CAM import CAM
cam, pre = CAM(model, images,
               last_conv_name='inception5b', fc_name='fc', 
               label=None, normalize=True, resize=True)