/visualize-pytorch

Pytorch implementation of gradCAM, guidedBackProp, smoothGrad

Primary LanguagePythonMIT LicenseMIT

gradCAM, guidedBackProp, smoothGrad on pytorch

Pytorch implementation of gradCAM, guidedBackProp, smoothGrad

Resnet50 is used in this implementation (also other models can be used)

dependencies

  • Python 3.6
  • torch 1.0.0
  • torchvison 0.2.1
  • cv2
  • tqdm

usage

install requirements

pip install -r requirements.txt

execute script

python main.py image_path --cuda --index hoge
  • add cuda option to use gpu

  • add index option to specify the target imagenet index of gradCAM

    Please see imagenet_class_index.json (e.g. ostrich: 9, tusker: 101)

    If not specified, target index will be estimated by the model

examples

ostrich.jpg elephant.jpg
raw
gradCAM
guidedBackProp
guidedGradCAM
smoothGrad