项目作者: tanjimin

项目描述 :
A customizable lightweight Grad-CAM implementation
高级语言: Python
项目地址: git://github.com/tanjimin/grad-cam-pytorch-light.git
创建时间: 2019-09-16T13:06:18Z
项目社区:https://github.com/tanjimin/grad-cam-pytorch-light

开源协议:GNU General Public License v3.0

下载


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

  1. from grad_cam import grad_cam
  2. 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