Skip to content

ksasi/fair-distill

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fair Distillation in GANs

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

Apace2 License Made With python 3.8.2 Pytorch

Requirements:

Clone the repository

git clone https://github.com/ksasi/fair-distill.git

Install using pip

pip install -r requirements.txt

Datasets:

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.

Architecture:

GAN_Bias_Estimator
Fair Distillation of GANs

Experimental Setup & Evaluation:

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

Data

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

Distillation

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.

Evaluation

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

Results:

Teacher GAN Teacher_GAN
Student GAN Student_GAN
Teacher_Race Student_Race
Teacher Race Student Race
Teacher_Race4 Student_Race4
Teacher Race4 Student Race4

References:

  1. FairFace
  2. TinyGAN

How to cite this repository

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}
}

About

Distillation of GANs with fairness constraints

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published