Official implementation for "Sum-of-Parts Models: Faithful Attributions for Groups of Features".
Authors: Weiqiu You, Helen Qu, Marco Gatti, Bhuvnesh Jain, Eric Wong
To set up the environment:
conda create -n sop python=3.10
conda activate sop
pip install -r requirements.txt
To do experiments on ImageNet first 10 classes, create a folder data/imagenet_m
with subfolders data/imagenet_m/train
and data/imagenet_m/val
, download data from ImageNet and put the 10 classes of data in subfolders in these folders.
To train SOP for 10 classes on ImageNet on the Huggingface's Vision Transformer google/vit-base-patch16-224
, first download our model for the first 10 classes for ImageNet.
python scripts/run/train_imagenet_m.py
or notebook notebooks/train.ipynb
.
To use the trained SOP wrapped model at inference time, checkout notebooks/eval.ipynb
.