Skip to content

Ainize project get your face image's gender,age,race

Notifications You must be signed in to change notification settings

leesangha/FairFace

 
 

Repository files navigation

Run on Ainize

FairFace: Face Attribute Dataset for Balanced Race, Gender, and Age

The paper: https://arxiv.org/abs/1908.04913

Kärkkäinen, K., & Joo, J. (2019). FairFace: Face Attribute Dataset for Balanced Race, Gender, and Age. arXiv preprint arXiv:1908.04913.

If you use our dataset or model in your paper, please cite:

@article{karkkainen2019fairface,
title={FairFace: Face Attribute Dataset for Balanced Race, Gender, and Age},
author={K{"a}rkk{"a}inen, Kimmo and Joo, Jungseock},
journal={arXiv preprint arXiv:1908.04913},
year={2019}
}

Examples of FairFace Prediction

test ### Instructions to use FairFace
  • Download or Clone this repo

  • Install Dependencies

    1. Please follow the Pytorch's official documentation to install Pytorch
    2. Please also install dlib, if you have pip installed on your system. Simply type the following command on your terminal.
    pip install dlib
    
  • Download our models Download our pretrained models from here and save it in the same folder as where predict.py is located. Two models are included, race_4 model predicts race as White, Black, Asian and Indian and race_7 model predicts races as White, Black, Latino_Hispanic, East, Southeast Asian, Indian, Middle Eastern.

  • Unzip the downloaded FairFace model as well as dlib face detection models in dlib_models.

  • Prepare the images

    • prepare a csv and provide the paths of testing images where the colname name of testing images is "img_path" (see our template csv file.

Run script predict.py

Run the predict.py script and provide the csv path (described in the section above).

python3 predict.py --csv "NAME_OF_CSV"

After download this repository, you can run python3 predict.pu --csv test_imgs.csv, the results will be available at detected_faces (in case dlib detect multiple faces in one image, we save them here) and test_outputs.csv.

Results

The results will be saved at "test_outputs.csv" (located in the same folder as predict.py, see sample here

UPDATES:

Run script predict_bbox.py

same commands as predict.py, the output csv will have additional column "bbox" which is the bounding box of detected face.

python3 predict_bbox.py --csv "NAME_OF_CSV"
output file documentation

indices to type

  • race_scores_fair (model confidence score) [White, Black, Latino_Hispanic, East, Southeast Asian, Indian, Middle Eastern]
  • race_scores_fair_4 (model confidence score) [White, Black, Asian, Indian]
  • gender_scores_fair (model confidence score) [Male, Female]
  • age_scores_fair (model confidence score) [0-2, 3-9, 10-19, 20-29, 30-39, 40-49, 50-59, 60-69, 70+]

Data

Images (train + validation set): Padding=0.25, Padding=1.25

We used dlib's get_face_chip() to crop and align faces with padding = 0.25 in the main experiments (less margin) and padding = 1.25 for the bias measument experiment for commercial APIs. Labels: Train, Validation

License: CC BY 4.0

Notes

The models and scripts were tested on a device with 8Gb GPU, it takes under 2 seconds to predict the 5 images in the test folder.

About

Ainize project get your face image's gender,age,race

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HTML 70.7%
  • Python 28.6%
  • Dockerfile 0.7%