Skip to content

tanjimin/grad-cam-pytorch-light

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

grad-cam-pytorch-light

Link: https://github.com/tanjimin/grad-cam-pytorch-light

A customizable lightweight implementation of Grad-CAM (Gradient-weighted Class Activation Mapping) arXiv. This implementation works for custom models.

Usage

from grad_cam import grad_cam

grad_cam(<Model>, <Image>, <Layer>, <Label>)

<Model>: A pytorch model. <Image>: Transformed image for caculating Grad-CAM, a three dimensional tensor. <Layer>: The layer to back-prop to for calculating gradients. <Label>: The label to start back-prop.

Example

See example.py for examples.

Sample Images

'Boxer' label and 'Tiger Cat' label for the same image:

Boxer Tiger Cat
Boxer Tiger Cat

'African elephant, Loxodonta africana' label for an image containing an elephant:

African elephant, Loxodonta africana
Elephant

About

A customizable lightweight Grad-CAM implementation

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages