Awesome
Explaining image classifiers by removing input features using generative models
This repository contains source code necessary to reproduce some of the main results in the paper:
If you use this software, please consider citing:
@inproceedings{agarwal2020explaining,
title={Explaining image classifiers by removing input features using generative models},
author={Agarwal, Chirag and Nguyen, Anh},
year={2020},
booktitle={Proceedings of the Asian Conference on Computer Vision (ACCV)},
year={2020}
}
1. Setup
Installing software
This repository is built using PyTorch. You can install the necessary libraries by pip installing the requirements text file pip install -r ./requirements.txt
Note: We ran our codes using tensorflow_gpu-1.12.0 with CUDA 9.0. Add the following lines in your ~/.bashrc file if you get "ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory" on running the code.
export PATH=/usr/local/cuda-9.0/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
2. Usage
The main scripts for SP/SP-G, LIME/LIME-G, and MP/MP-G are in formal_SP_single_image.py, formal_LIME_single_image.py, and formal_MP_single_image.py. In addition, after installing the LIME library you will have to replace the lime_image.py script with our lime_image.py. Three shell scripts have been provided which for a given an image and target class generates its respective attribution maps for an algorithm and its generative version.
Examples
SP_test.sh: Generating the attribution map for the class "freight car" using SP and SP-G algorithm.
- Running
source SP_test.sh
produces this result:
LIME_test.sh: Generating the attribution map for the class "kuvasz" using LIME and LIME-G algorithm.
- Running
source LIME_test.sh
produces this result:
MP_test.sh: Generating the attribution map for the class "freight car" using MP and MP-G algorithm.
- Running
source MP_test.sh
produces this result:
4. Licenses
Note that the code in this repository is licensed under MIT License, but, the pre-trained condition models used by the code have their own licenses. Please carefully check them before use.
5. Questions?
If you have questions/suggestions, please feel free to email or create github issues.