Skip to content

Bernardo1998/FairGRAPE

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FairGRAPE: Fairness-aware GRAdient Pruning mEthod for Face Attribute Classification

This repo presents an official implementation of FairGRAPE: Fairness-aware GRAdient Pruning mEthod for Face Attribute Classification

FairGRAPE_concept2

Dependencies

The code has been tested on the following environment:

python 3.9
pytorch 1.11.0
dlib 19.22.0
opencv2 4.5.5

Use Anaconda and the following command to replicate the full environment:

conda env create -f environment.yml

Datasets

This code automatically downloads the following datasets for trianing, cross validation and testing: FairFace, UTKFace and CelebA. Request demographics labels of the Imagenet person subtree through the offical database, save the annotation file under /csv and images under /Images/Imagenet.

Example Usage:

UTKFace experiments:

python main_test.py --sensitive_group 'gender' --loss_type 'race' --prune_type 'FairGRAPE' --network 'resnet34' --dataset 'UTKFace'  --prune_rate 0.9 --keep_per_iter 0.975

FairFace experiments

python main_test.py --sensitive_group race--loss_type 'race' --prune_type 'FairGRAPE' --network 'resnet34' --dataset 'FairFace'  --prune_rate 0.99

CelebA experiments

python main_test.py --sensitive_group 'gender' --loss_type 'classes' --prune_type 'FairGRAPE' --network 'mobilenetv2' --dataset 'CelebA' --prune_rate 0.9

Imagenet experiments:

python main_test.py --sensitive_group 'gender' --loss_type 'classes' --prune_type 'FairGRAPE' --network 'resnet34' --dataset 'Imagenet'  --prune_rate 0.5

Download trained models here.

Loading a trained model:

python main_test.py --sensitive_group 'gender' --loss_type 'race' --prune_type 'FairGRAPE' --network 'mobilenetv2'--dataset 'UTKFace'  --prune_rate 0.9 --keep_per_iter 0.975 --checkpoint "UTKFace_FairGRAPE_race_bygender_resnet34_0.9_0.pt" --init_train 0 --retrain 0 --print_acc 1

Acknowledgement

Parts of code were borrowed from SNIP, WS, GraSP

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages