This repository contains a lightweight model for face age and gender estimation. The model is very small and efficient about 1MB size, 10ms on single CPU core. Gender accuracy 96% on validation set and 4.1 age MAE.
Two methods (MTCNN and ESSH) are both provided in this repository for face detection and alignment. For easy cases, the results of two methods are almost the same, however, on hard cases the ESSH method has a much better detection results. You can use python test.py --det 0
to choose MTCNN method, or use python test.py --det 1
for ESSH.
This repository has been tested under the following environment:
- Python 2.7
- Ubuntu 18.04
- Mxnet-cu90 (==1.3.0)
-
Prepare the environment.
-
Clone the repository.
-
Type
make
to build necessary cxx libs.
You can download rec format file directly in here: BaiduCloud or GoogleDrive , or package it youself according to the following steps
- Download IMDB-WIKI dataset (face only) from https://data.vision.ee.ethz.ch/cvl/rrothe/imdb-wiki/.
- Unzip them under
./data
or others path. - Pre-process each images in dataset and package it in a rec file.
You can first train on imdb, then fine tune on wiki dataset. Train MobileNet 0.25X on a GPU such as GTX-1080Ti according to the following command
CUDA_VISIBLE_DEVICES='0' python -u train.py --data-dir $DATA_DIR --prefix './models/model' --network m1 --multiplier 0.25 --per-batch-size 128 --lr 0.01 --lr-steps '10000' --ckpt 2
Instead, you can edit train.sh
and run sh ./train.sh
to train your models.
-
Download the ESSH model from BaiduCloud or GoogleDrive and place it in
./ssh-model/
. -
You can use
python test.py
to test the pre-trained models or your own models.
Results of face age and gender estimation (inferenced from model MobileNet 0.25X) are shown below.
MIT LICENSE
The code is adapted based on an intial fork from the insightface repository.