Skip to content

Official PyTorch implementation for the paper "Interpretable Image Classification via Non-parametric Part Prototype Learning" CVPR 2025.

Notifications You must be signed in to change notification settings

zijizhu/proto-non-param

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Interpretable Image Classification via Non-parametric Part Prototype Learning

[Paper] [BibTeX]

This repository presents the official PyTorch implementation for the paper "Interpretable Image Classification via Non-parametric Part Prototype Learning".

Environment Setup

Setting up the environment involves the following steps:

  • Install required Python packages listed in requirements.txt,
  • Install dinov2 without its dependencies for better compatibility (mainly to exclude xformers). We use commit e1277af of dinov2 repository. Additionally, please ensure the PyTorch version meets torch<2.4.0 to avoid performance regression.

To install Python packages used in this repository:

pip install -r requirements.txt

To install dinov2 without installing xformers:

git clone https://github.com/facebookresearch/dinov2.git
cd dinov2
git checkout e1277af2ba9496fbadf7aec6eba56e8d882d1e35
pip install --no-deps -e .

Data Preparation

Please prepare the dataset as follows:

  • Download CUB-200-2011 dataset from the official website.
  • Perform offline data augmentation on the dataset following previous works, such as by modifying this script.
  • For evaluation, please also download the object segmentation masks.
  • Make sure all the data folders are placed under one dataset root directory, which looks like the following after extracting archives:
dataset-root
├── CUB_200_2011/
├── cub200_cropped/
└── segmentations/

Training and Evaluation

To train the model on CUB-200-2011, run the following command after replacing the arguments with dataset root directory and logging directory:

python train.py --data-dir <dataset-root> --log-dir <log-directory>

To evaluate the trained model:

  • First change line 19 of eval/utils.py so it points to <dataset-root>.
  • Run the following command after changing the argument to the previous logging directory that contains training artifacts (keep ckpt.pth at the end):
python evaluate.py --ckpt-path <log-directory>/ckpt.pth

Cite Our Work

@InProceedings{Zhu_2025_CVPR,
    author    = {Zhu, Zhijie and Fan, Lei and Pagnucco, Maurice and Song, Yang},
    title     = {Interpretable Image Classification via Non-parametric Part Prototype Learning},
    booktitle = {Proceedings of the Computer Vision and Pattern Recognition Conference (CVPR)},
    month     = {June},
    year      = {2025},
    pages     = {9762-9771}
}

About

Official PyTorch implementation for the paper "Interpretable Image Classification via Non-parametric Part Prototype Learning" CVPR 2025.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Languages