Skip to content

Latest commit

 

History

History
60 lines (41 loc) · 2.4 KB

README.md

File metadata and controls

60 lines (41 loc) · 2.4 KB

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