Skip to content

PyTorch implementation of class activation mapping

Notifications You must be signed in to change notification settings

wolfapple/pytorch-cam

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PyTorch implementation of class activation mapping

Class Activation Mapping (CAM)

Paper and Archiecture: Learning Deep Features for Discriminative Localization

Paper Author Implementation: metalbubble/CAM

The framework of the Class Activation Mapping is as below:

I modified a pre-trained VGG19 network with Global Average Pooling and Convolution. It was trained by using STL10 about 5000 images with 10 classes.

Configure and Manage Your Environment with Anaconda

Per the Anaconda docs:

Conda is an open source package management system and environment management system for installing multiple versions of software packages and their dependencies and switching easily between them. It works on Linux, OS X and Windows, and was created for Python programs but can package and distribute any software.

Using Anaconda consists of the following:

  1. Install miniconda on your computer, by selecting the latest Python version for your operating system. If you already have conda or miniconda installed, you should be able to skip this step and move on to step 2.
  2. Create and activate * a new conda environment.

* Each time you wish to work on any exercises, activate your conda environment!


1. Installation

Download the latest version of miniconda that matches your system.

Linux Mac Windows
64-bit 64-bit (bash installer) 64-bit (bash installer) 64-bit (exe installer)
32-bit 32-bit (bash installer) 32-bit (exe installer)

Install miniconda on your machine. Detailed instructions:

2. Create and Activate the Environment

For Windows users, these following commands need to be executed from the Anaconda prompt as opposed to a Windows terminal window. For Mac, a normal terminal window will work.

  1. Clone the repository, and navigate to the downloaded folder. This may take a minute or two to clone due to the included image data.
git clone https://github.com/wolfapple/pytorch-cam.git
cd pytorch-cam
  1. Create (and activate) a new environment, named pytorch-cam. Running this command will create a new conda environment that is provisioned with all libraries you need to be successful in this program.
  • Linux or Mac:
conda env create -f environment.yaml
source activate pytorch-cam
  • Windows:
conda env create -f environment.yaml
activate pytorch-cam

At this point your command line should look something like: (pytorch-cam) <User>:pytorch-cam <user>$. The (pytorch-cam) indicates that your environment has been activated, and you can proceed with further package installations.

  1. Verify that the environment was created in your environments:
conda info --envs
  1. Cleanup downloaded libraries (remove tarballs, zip files, etc):
conda clean -tp
  1. That's it!

Now most of the libraries are available to you. Very occasionally, you will see a repository with an addition requirements file, which exists should you want to use TensorFlow and Keras, for example. In this case, you're encouraged to install another library to your existing environment, or create a new environment for a specific project.

To exit the environment when you have completed your work session, simply close the terminal window.

3. Uninstalling

To uninstall the environment:

conda env remove -n pytorch-cam

About

PyTorch implementation of class activation mapping

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published