Skip to content

hcmlab/GANterfactual

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GANterfactual

Generating Counterfactual Explanation Images through Generative Adversarial Learning.

Example Counterfactual Images

This repository aims to provide the code used in the paper "GANterfactual - Counterfactual Explanations for Medical Non-Experts using Generative Adversarial Learning".

The dataset used in the paper can be downloaded here. Once you have downloaded it, you can split it into the required data partitions by using the preprocessor.py script that can be found in the data directory. Run it by executing the following command in a terminal:

python preprocessor.py -i path_of_raw_dataset -t 20 -v 10 -d 512

This will split your dataset into train, validation and test partitions (70% train, 20% test, 10% validation). The data will be written to the respective subdirectories in the data directory.

To train the classifier that was used in the paper, use the train_alexNet.py script in the GANterfactual directory:

python train_alexNet.py

The final classifier model will be stored at models/classifier/model.h5

To train the the GANterfactual model, that consists of a CycleGAN that is modified with an additional counterfactual loss component, use the cyclegan.py script in the GANterfactual directory:

python cyclegan.py

The four parts of the final GANterfactual model will be stored at models/GANterfactual.

Our used inference scripts will be added soon.

Our pre-trained models will be provided for download soon as well.

About

Generating Counterfactual Explanation Images through Generative Adversarial Learning

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages