Skip to content
liuktcPublic

About

Code for the paper "How to Evaluate and Refine your CAM"

Resources

Stars

5 stars

Watchers

0 watching

Forks

Repository files navigation

ICPR 2026     IAPR TC22 Reproducibility

How to Evaluate and Refine your CAM

Faithful CAM evaluation, a ground-truth benchmark, and high-resolution attribution maps.

arXiv Project Website Reproducibility Badge

Overview of RefineCAM and CAM evaluation

RefineCAM produces fine-grained attribution maps by combining information across multiple network layers.


Highlights

This work addresses two complementary problems in the evaluation and refinement of Class Attribution Maps (CAMs):

  • RefineCAM combines CAMs across multiple network layers to produce higher-resolution and better-focused attribution maps.
  • ARCC is a composite metric designed for more reliable evaluation of CAM explanations.
  • Synthetic CAM Benchmark provides ground-truth attributions for systematically evaluating explanation metrics.

Installation

Implementations of both RefineCAM and ARCC are integrated into the widely used pytorch-grad-cam library.

pip install grad-cam

RefineCAM can be imported directly with:

from pytorch_grad_cam import RefineCAM

ARCC is available as an evaluation metric:

from pytorch_grad_cam.metrics.ARCC import ARCC

For the maintained implementation and usage documentation, see pytorch-grad-cam.

Example Usage

from pytorch_grad_cam import GradCAMPlusPlus, RefineCAM
from pytorch_grad_cam.metrics.arcc import ARCC

# Load model and input image
model = ...
input_tensor = ...
target = ...

# Standard CAM
gradcam = GradCAMPlusPlus(
    model=model,
    target_layers=[model.layer4[-1]],
)
gradcam_result = gradcam(input_tensor, targets=target)

# RefineCAM combines CAMs from multiple layers
refinecam = RefineCAM(
    model=model,
    target_layers=[
        model.layer1[-1],
        model.layer2[-1],
        model.layer3[-1],
        model.layer4[-1],
    ],
)
refinecam_result = refinecam(input_tensor, targets=target)

# Evaluate both explanations with ARCC
gradcam_score = ARCC(base_method=gradcam)(
    input_tensor, gradcam_result, targets=target, model=model
)

refinecam_score = ARCC(base_method=refinecam)(
    input_tensor, refinecam_result, targets=target, model=model
)

See example.py for a complete runnable example with ResNet18, image loading, visualization, and ARCC evaluation. Running example.py will produce this:

Comparison of GradCAM++ vs RefineCAM evaluated with ARCC

Paper

How to Evaluate and Refine Your CAM

Luca Domeniconi, Alessandra Stramiglio, Michele Lombardi, Samuele Salti

Project Website · arXiv · PDF · pytorch-grad-cam

Citation

If you use RefineCAM, ARCC, or the synthetic benchmark, please cite:

@inproceedings{domeniconi2026evaluate,
  title={How to Evaluate and Refine your CAM},
  author={Domeniconi, Luca and Stramiglio, Alessandra and Lombardi, Michele and Salti, Samuele},
  booktitle={International Conference on Pattern Recognition},
  pages={543--557},
  year={2026},
  organization={Springer}
}

About

Code for the paper "How to Evaluate and Refine your CAM"

Resources

Stars

5 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages