Code for paper: Group-CAM: Group Score-Weighted Visual Explanations for Deep Convolutional Networks

Overview

Group-CAM

By Zhang, Qinglong and Rao, Lu and Yang, Yubin

[State Key Laboratory for Novel Software Technology at Nanjing University]

This repo is the official implementation of "Group-CAM: Group Score-Weighted Visual Explanations for Deep Convolutional Networks".

Approach

Figure 1: Pipeline of Group-CAM.

Target layer

ResNet: 'layer4.2', Vgg19: 'features.35'

Citing Group-CAM

@article{zhql2021gc,
  title={Group-CAM: Group Score-Weighted Visual Explanations for Deep Convolutional Networks},
  author={Zhang, Qinglong and Rao, Lu and Yang, Yubin},
  journal={arXiv preprint arXiv:2103.13859},
  year={2021}
}
Comments
  • code bug

    code bug

    I got some confusion about the code in main.py line 315.images = images * saliency_maps + blur(images) + (1-saliency_maps). What do you mean to plus the (1 - saliency_maps) here? And what's the size of the saliency_maps here?

    opened by Jiawei0o0 2
  • Can't generate Group-CAM saliency map

    Can't generate Group-CAM saliency map

    Thanks for sharing the code.

    I tried to Generate saliency map used by Group-CAD, but couldn't.

    python3 demo.py --arch=vgg19 --target_layer=features.35 --input=Images/ILSVRC2012_val_00000073.JPEG --output=base.png
    
    # demo.py, l48
    
    gc = GroupCAM(model, target_layer=args.target_layer)
    

    base

    opened by ryhhtn 0
  • Using GroupCAM, get a NoneType

    Using GroupCAM, get a NoneType

    I use your groupcam code, but I get the NoneType

    image

    Here is my code:

    def cam(model, loader, target_layer='conv1'):
        gc = GroupCAM(model, target_layer=target_layer)
        for i, (data, target) in enumerate(loader):
            if torch.cuda.is_available():
                data = data.cuda(non_blocking=True)
                target = target.cuda(non_blocking=True)
            saliency_maps = []
            model.eval()
            for idx in range(data.shape[0]):
                image = data[idx].unsqueeze(0)
                if idx == data.shape[0] - 1:
                    saliency = gc(image, class_idx=target[idx], retain_graph=False)
                else:
                    saliency = gc(image, class_idx=target[idx], retain_graph=True)
                saliency = saliency.to(device)
                saliency_maps.append(saliency)
            saliency_maps = torch.cat(saliency_maps, dim=0)
            mean = torch.mean(saliency_maps)
            saliency_maps = torch.where(saliency_maps < mean, 0.0, 1.0)
    

    The model is my DNN, and the loader is the CIFAR-10 eval_loader,

    My PyTorch version: '1.12.1+cu116' Python version: 3.7

    opened by 1zeryu 2
  • about details on insertion and deletion evaluation

    about details on insertion and deletion evaluation

    Hi, thanks for sharing your code that is very useful. I just have a simple question. In the paper, you said you the number of replaced pixels is 224 x 8, but in your code, it is 224 x 2. Which one do you recommend for experiments? In the previous papers, it is around one per cent that is close to 224 x 2. What is your reason that you choose 3.6%? Thanks.

    opened by neouyghur 0
  • Codes for the localization evaluation part.

    Codes for the localization evaluation part.

    Hi, I have seen your paper and you have done a splendid job on the class activation maps generating algorithm. Also, you have uploaded your codes for the sanity check, deletion and insertion, as well as finetuning the classification network. I am wondering it would be very kind of you to upload your codes for the localization evaluation, too. So, is that uploading possible?

    Thanks, Ema1997.

    opened by Ema1997 1
Owner
zhql
Machine Learning Bricklayer
zhql
This repository implements and evaluates convolutional networks on the Möbius strip as toy model instantiations of Coordinate Independent Convolutional Networks.

Orientation independent Möbius CNNs This repository implements and evaluates convolutional networks on the Möbius strip as toy model instantiations of

Maurice Weiler 59 Dec 9, 2022
Puzzle-CAM: Improved localization via matching partial and full features.

Puzzle-CAM The official implementation of "Puzzle-CAM: Improved localization via matching partial and full features".

Sanghyun Jo 150 Nov 14, 2022
DL & CV-based indicator toolset for the vehicle drivers via live dash-cam footage.

Vehicle Indicator Toolset Deep Learning and Computer Vision based indicator toolset for vehicle drivers using live dash-cam footages. Tracking of vehi

Alex Xu 12 Dec 28, 2021
I tried to apply the CAM algorithm to YOLOv4 and it worked.

YOLOV4:You Only Look Once目标检测模型在pytorch当中的实现 2021年2月7日更新: 加入letterbox_image的选项,关闭letterbox_image后网络的map得到大幅度提升。 目录 性能情况 Performance 实现的内容 Achievement

null 55 Dec 5, 2022
Codes for TS-CAM: Token Semantic Coupled Attention Map for Weakly Supervised Object Localization.

TS-CAM: Token Semantic Coupled Attention Map for Weakly SupervisedObject Localization This is the official implementaion of paper TS-CAM: Token Semant

vasgaowei 112 Jan 2, 2023
Code for our ICASSP 2021 paper: SA-Net: Shuffle Attention for Deep Convolutional Neural Networks

SA-Net: Shuffle Attention for Deep Convolutional Neural Networks (paper) By Qing-Long Zhang and Yu-Bin Yang [State Key Laboratory for Novel Software T

Qing-Long Zhang 199 Jan 8, 2023
This project is a loose implementation of paper "Algorithmic Financial Trading with Deep Convolutional Neural Networks: Time Series to Image Conversion Approach"

Stock Market Buy/Sell/Hold prediction Using convolutional Neural Network This repo is an attempt to implement the research paper titled "Algorithmic F

Asutosh Nayak 136 Dec 28, 2022
Generating Anime Images by Implementing Deep Convolutional Generative Adversarial Networks paper

AnimeGAN - Deep Convolutional Generative Adverserial Network PyTorch implementation of DCGAN introduced in the paper: Unsupervised Representation Lear

Rohit Kukreja 23 Jul 21, 2022
PyTorch framework, for reproducing experiments from the paper Implicit Regularization in Hierarchical Tensor Factorization and Deep Convolutional Neural Networks

Implicit Regularization in Hierarchical Tensor Factorization and Deep Convolutional Neural Networks. Code, based on the PyTorch framework, for reprodu

Asaf 3 Dec 27, 2022
CoSMA: Convolutional Semi-Regular Mesh Autoencoder. From Paper "Mesh Convolutional Autoencoder for Semi-Regular Meshes of Different Sizes"

Mesh Convolutional Autoencoder for Semi-Regular Meshes of Different Sizes Implementation of CoSMA: Convolutional Semi-Regular Mesh Autoencoder arXiv p

Fraunhofer SCAI 10 Oct 11, 2022
Applications using the GTN library and code to reproduce experiments in "Differentiable Weighted Finite-State Transducers"

gtn_applications An applications library using GTN. Current examples include: Offline handwriting recognition Automatic speech recognition Installing

Facebook Research 68 Dec 29, 2022
audioLIME: Listenable Explanations Using Source Separation

audioLIME This repository contains the Python package audioLIME, a tool for creating listenable explanations for machine learning models in music info

Institute of Computational Perception 27 Dec 1, 2022
PyTorch implementation of Interpretable Explanations of Black Boxes by Meaningful Perturbation

PyTorch implementation of Interpretable Explanations of Black Boxes by Meaningful Perturbation The paper: https://arxiv.org/abs/1704.03296 What makes

Jacob Gildenblat 322 Dec 17, 2022
Collection of NLP model explanations and accompanying analysis tools

Thermostat is a large collection of NLP model explanations and accompanying analysis tools. Combines explainability methods from the captum library wi

null 126 Nov 22, 2022
📦 PyTorch based visualization package for generating layer-wise explanations for CNNs.

Explainable CNNs ?? Flexible visualization package for generating layer-wise explanations for CNNs. It is a common notion that a Deep Learning model i

Ashutosh Hathidara 183 Dec 15, 2022
Image-popularity-score - A novel deep regression method for image scoring.

Image-popularity-score - A novel deep regression method for image scoring.

Shoaib ahmed 1 Dec 26, 2021
Repository for the "Gotta Go Fast When Generating Data with Score-Based Models" paper

Gotta Go Fast When Generating Data with Score-Based Models This repo contains the official implementation for the paper Gotta Go Fast When Generating

Alexia Jolicoeur-Martineau 89 Nov 9, 2022
Monocular Depth Estimation - Weighted-average prediction from multiple pre-trained depth estimation models

merged_depth runs (1) AdaBins, (2) DiverseDepth, (3) MiDaS, (4) SGDepth, and (5) Monodepth2, and calculates a weighted-average per-pixel absolute dept

Pranav 39 Nov 21, 2022
Automatic differentiation with weighted finite-state transducers.

GTN: Automatic Differentiation with WFSTs Quickstart | Installation | Documentation What is GTN? GTN is a framework for automatic differentiation with

null 100 Dec 29, 2022