Skip to content

Keras implementation of a CNN network for age and gender estimation

License

Notifications You must be signed in to change notification settings

b-g/age-gender-estimation

Repository files navigation

Age and Gender Estimation

This is a Keras implementation of a CNN network for estimating age and gender from a face image [1, 2]. In training, the IMDB-WIKI dataset is used.

Dependencies

  • Python3.5+
  • Keras2.0+
  • scipy, numpy, Pandas, tqdm, tables, h5py
  • dlib (for demo)
  • OpenCV3

Tested on:

  • Ubuntu 16.04, Python 3.5.2, Keras 2.0.3, Tensorflow(-gpu) 1.0.1, CUDA 8.0, cuDNN 5.0
  • macOS Sierra, Python 3.6.0, Keras 2.0.2, Tensorflow 1.0.0

Usage

Use pretrained model

Download pretrained model

mkdir -p pretrained_models
wget -P pretrained_models https://www.dropbox.com/s/rf8hgoev8uqjv3z/weights.18-4.06.hdf5

Run demo script (requires web cam)

python3 demo.py

Train a model using the IMDB-WIKI dataset

Download the dataset

The dataset is downloaded and extracted to the data directory.

./download.sh

Create data

Filter out noise data and serialize images and labels for training into .mat file. Please check check_dataset.ipynb for the details of the dataset.

python3 create_db.py --output data/imdb_db.mat --db imdb --img_size 64

Train network

Train the network using the training data created above.

python3 train.py --input data/imdb_db.mat

Plot training curves from history file.

python3 plot_history.py --input models/history_16_8.h5 

Network architecture

In the original paper [1, 2], the pretrained VGG network is adopted. Here the Wide Residual Network (WideResNet) is trained from scratch. I modified the @asmith26's implementation of the WideResNet; two classification layers (for age and gender estimation) are added on the top of the WideResNet.

Note that while age and gender are independently estimated by different two CNNs in [1, 2], in my implementation, they are simultaneously estimated using a single CNN.

Results

Trained on imdb, tested on wiki.

References

[1] R. Rothe, R. Timofte, and L. V. Gool, "DEX: Deep EXpectation of apparent age from a single image," ICCV, 2015.

[2] R. Rothe, R. Timofte, and L. V. Gool, "Deep expectation of real and apparent age from a single image without facial landmarks," IJCV, 2016.

About

Keras implementation of a CNN network for age and gender estimation

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Jupyter Notebook 90.0%
  • Python 9.8%
  • Other 0.2%