Skip to content

Latest commit

 

History

History
34 lines (23 loc) · 1018 Bytes

README.md

File metadata and controls

34 lines (23 loc) · 1018 Bytes

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