This repository contains code to conduct dataset debiasing experiments using generative models. There are many reasons as to why a machine learning model may be biased (for a comprehensive survey see link), but one of the most common ones is due to a biased dataset.
This is a work in progress, and the objectives and details of the experiments are continuously evolving. As of now, I'm working on the following two aspects: Given a biased dataset,
- use variational auto-encoders (VAEs) to find what is missing (more specifically, the under-represented features).
- use generative adversarial networks (GANs) to generate what is missing (duplicate images with the under-represented features).
Create a python virtual environment and install the latest TensorFlow version. Then run
$ pip install -r requirements.txt
$ pip install -e .
NVIDIA Container Toolkit is needed for GPU support.
Change the USER_NAME, USER_ID and GROUP_ID build time variables inside the Dockerfile corresponding to your user (use id -u and id -g to find your USER_ID and GROUP_ID respectively).
Train the variational autoencoder. The network architecture is given in models/vae.py.
$ python train_vae.py -o output_dir
Run the notebook notebooks/01_visualize_vae_output.ipynb to visualize training results.
Use the VAE to extract a minority dataset.
$ python extract_minority_dataset.py -w checkpoint_dir -d destination_dir
The size of this minority dataset (as a percentage of the original) can be adjusted within the code. Run the notebook notebooks/02_inspect_minority_dataset.ipynb to understand the different properties of the minority dataset thus created.
Train a generative adversarial network on the minority dataset that we just created. I am using StyleGAN2-ADA-PyTorch made available by Nvidia Research Projects.