AgeTransGAN — Official Pytorch Implementation

Linux Python 3.6 CUDA 10.1 Pytorch 1.4 Tensorflow 2.1

Teaser image

Samples: Made by the AgeTransGAN for age regression and progression. The face in the red bbox is the input, and the rest are generated aged faces, all in 10242 pixels.

Abstract: We propose the AgeTransGAN for facial age transformation and the improvements to the metrics for performance evaluation. The AgeTransGAN is composed of an encoder-decoder generator and a conditional multitask discriminator with an age classifier embedded. The generator exploits cycle-generation consistency, age classification and cross-age identity consistency to disentangle the identity and age characteristics during training. The discriminator fuses age features with the target age group label and collaborates with the embedded age classifier to warrant the desired age traits made on the generated images. As many previous work use the Face++ APIs as the metrics for performance evaluation, we reveal via experiments the inappropriateness of using the Face++ as the metrics for the face verification and age estimation of juniors. To rectify the Face++ metrics, we made the Cross-Age Face (CAF) dataset which contains 4000 face images of 520 individuals taken from their childhood to senior hood. The CAF is one of the very few datasets that offer much more images of the same individuals across large age gaps than the popular FG-Net.We use the CAF to rectify the face verification thresholds of the Face++ APIs across different age gaps. We also use the CAF and the FFHQ-Aging datasets to compare the age estimation performance of the Face++ APIs and an age estimator made by our own, and propose rectified metrics for performance evaluation. We compare the performance of the AgeTransGAN and state-of-the-art approaches by using the existing and rectified metrics.

Test and Demo

We offer two versions of our AgeTransGAN, one for 10-age-group and the other for 4-age-group. You can enter your image as the input and our AgeTransGAN generator will generate 10 or 4 aged faces as output by the following steps (it requires Linux, Python 3.6, Cuda 10.1, Pytorch 1.40, Tensorflow 2.10):

  1. Change the default input image 1.jpg in ./test/run_10group.sh or ./test/run_4group.sh for using the 10-group generator or 4-group generator.
> ./test/run_10group.sh
python main.py --img_size 1024 --group 10 --batch_size 16 --snapshot ./snapshot/ffhq_10group_910k.pt --file img/1.jpg
deactivate
> ./test/run_4group.sh
python main.py --img_size 1024 --group 4 --batch_size 16 --snapshot ./snapshot/ffhq_4group_750k.pt --file img/1.jpg
deactivate
  1. Run the test code with ./test/run_10group.sh or ./test/run_4group.sh.

  2. The outputs are written to a new directory /test/result/<10>-<4>.

  3. You can also use a camera to take a face as input for a live synthesis. Please run the code with ./demo/run_10group.sh or ./demo/run_4group.sh.

Use of Face++ APIs

The steps of using the Face++ APIs for estimating the age of a face image are as follows:

  1. Open ./faceplusplus_evaluation-master/age.sh and ./faceplusplus_evaluation-master/face_verification.sh, and enter the key.
-F "api_key=[Yours]" \ -F "api_secret=[Yours]" \
  1. Run the above code and obtain the csv files:
./age.sh [Folders for specific age groups] [Corresponding csv files]
./face_ verification.sh [Folders for specific age groups] [Folders for original images] [Corresponding csv files]

Use of Age estimator

Use our age estimator, first download the pretrained weight: Age estimator

Put the pretrained under /age_estimator/weights/mean_variance_ffhq

Than run the main_test.py and obtain the csv files as follows:

python main_test.py

Perfromance

The table shows performance on FFHQ-Aging for transferring Group-5 to other 9 groups, estimate age with our estimator and Face++. We also shows the defined threshold for each group to caculate our face verification rate.

Age group 0-2 3-6 7-9 10-14 15-19 30-39 40-49 50-59 70+
Average of Estimated Age
Face++ 8.3 17.7 21.7 24.6 21.1 37.8 50.3 65.8 75.7
Provide estimator 1.1 4.5 8.8 13.5 18.7 32.3 41.7 55.5 68.4
Verification Rate (%)
Threshold 61.8 68.9 72.7 74.2 76.6 76.3 71.7 65.2 65.2
Ver. rate(%) 80.26 96.46 95.91 95.76 100 100 100 97.60 96.78

Checkpoints Download

FFHQ-4Groups

FFHQ-10Groups

Cross Age Face dataset

The dataset consists of 4000 images of 520 subject collected from the google search. Each image is labeled with ground-truth age. The numbers of subjects in group 0 ~ group 9 are 341, 364, 312, 399, 469, 515, 435, 296 ,195, and 67, respectively. Unprocess images is avaliable here CAF dataset. Images categorized by age group is avaliable here CAF group dataset.

Training Networks

Expected training times for the default configuration using Nvidia Titan RTX GPU:

256*256 pixels:

MORPH: 1 day 12 hours, CACD: 4 days

1024*1024 pixels:

FFHQ-Aging 4Groups: 24 days, FFHQ-Aging 10Groups: 31 days