Skip to content

MadryLab/EditingClassifiers

Repository files navigation

This repository contains the code and data for our paper:

Editing a classifier by rewriting its prediction rules
Shibani Santurkar*, Dimitris Tsipras*, Mahi Elango, David Bau, Antonio Torralba, Aleksander Madry
Paper: https://arxiv.org/abs/2112.01008

    @InProceedings{santurkar2021editing,
        title={Editing a classifier by rewriting its prediction rules},
        author={Shibani Santurkar and Dimitris Tsipras and Mahalaxmi Elango and David Bau and Antonio Torralba and Aleksander Madry},
        year={2021},
        booktitle={Neural Information Processing Systems (NeurIPS)}
    }

Getting started

You can start by cloning our repository and following the steps below. Parts of this codebase have been derived from the GAN rewriting repository of Bau et al.

  1. Install the dependencies for our code using Conda. You may need to adjust the environment YAML file depending on your setup.

    conda env create -f environment.yaml
    
  2. Download model checkpoints and extract them in the current directory.

  3. To instantiate CLIP

    git submodule init
    git submodule update
    
    
  4. Replace IMAGENET_PATH in helpers/classifier_helpers.py with the path to the ImageNet dataset.

  5. (If using synthetic examples) Download files segmentations.tar.gz and styles.tar.gz and extract them under ./data/synthetic.

  6. (If using synthetic examples) Run

     python stylize.py -style_name [STYLE_FILE_NAME]

with the desired style file from ./data/synthetic/styles. You could also use a custom style file if desired.

That's it! Now you can explore our editing methodology in various settings: vehicles-on-snow, typographic attacks and synthetic test cases.

Maintainers