Distillation of GANs with fairness constraints
This work is carried out as part of my Masters Thesis - "Bias and Fairness in Low Resolution Image Recognition" under the guidance of Dr. Mayank Vatsa and Dr. Richa Singh
Clone the repository
Install using pip
pip install -r requirements.txt
Dataset | Description |
---|---|
BFW | This is balanced across eight subgroups. This consists of 800 face images of 100 subjects, each with 25 face samples.The BFW dataset is grouped into ethnicities (i.e., Asian (A), Black (B), Indian (I), and White (W)) and genders (i.e., Females (F) and Males (M)) shown in (b) figure 2.2.1. The metadata for this dataset consists of list of pairs for face verification. Hence, this dataset can be used to investigate bias in automatic facial recognition (FR) system for verification protocol. |
Fair Distillation of GANs |
Clone StyleGAN2-ADA repository
git clone https://github.com/NVlabs/stylegan2-ada-pytorch.git
Clone FairFace repository
git clone https://github.com/dchen236/FairFace.git
Create alltrain
, alltest
, disttrain
, disttest
folders in <root_folder>/fair-distill/data/
location
Create st_latents
, te_images
and st_images
folders in <root_folder>/fair-distill/data/stdata
location
Generate synthetic faces from teacher GAN (StyleGAN) by executing stylegan2_generator.py in src folder under fair-distill as below :
python stylegan2_generator.py --num=80000 --outdir=../data/alltrain python generate_csv.py --imgdir=../data/alltrain --outdir=../results
Navigate to FairFace folder and execute scripts as below :
rm -rf detected_faces
python predict.py --csv <root_folder>/fair-distill/results test_imgs.csv
cp test_outputs.csv ../fairDL/results/test_outputs_1.csv
Sample images from alltrain
to disttrain
based on the attributes such that all groups are balanced as below :
python sampler.py --src=<root_folder>/fair-distill/data/alltrain --tgt=<root_folder>/fair-distill/data/disttrain --predfile=<root_folder>/fair-distill/results/test_outputs_1.csv
Naviate to scripts
folder and execute as shown below :
sh run.sh
Obtain the best checkpoint of the distilled Student GAN by visual inspection of generated faces.
Generate faces from the distilled Student GAN and Teacher GAN as below :
student_generator.py --num=5000 --stimgdir=<root_folder>/fair-distill/data/stdata/st_images --stlatdir=<root_folder>/fair-distill/data/stdata/st_latents --teimgdir=<root_folder>/fair-distill/data/stdata/te_images --model_checkpoint=<root_folder>/fair-distill/checkpoints/<best_student_GAN_checkpoint>
Generate attribute plots (race, race4 and others) from Student GAN generated faces as below :
python generate_csv.py --imgdir=<root_folder>/fair-distill/data/stdata/st_images --outdir=<root_folder>/fair-distill/results
sh pred.sh
python plot.py --src=<root_folder>/fair-distill/results/img_outputs.csv --outdir=<root_folder>/fair-distill/results
Teacher GAN | |
---|---|
Student GAN |
Teacher Race | Student Race |
Teacher Race4 | Student Race4 |
If you used this repository in your work, please cite it as below:
@software{face-distill,
author = {Sasikanth, Kotti},
title = {{Fair Distillation in GANs}},
year = {2022},
url = {https://github.com/ksasi/fair-distill}
}