项目作者: tringn

项目描述 :
Age Gender Prediction by Caffe
高级语言: Python
项目地址: git://github.com/tringn/AgeGenderPrediction.git
创建时间: 2018-11-21T06:29:37Z
项目社区:https://github.com/tringn/AgeGenderPrediction

开源协议:

下载


AgeGenderPrediction

These models are based on this paper

Network Architecture

net_architecture

The network contains three convolutional layers, each followed by a rectified linear operation and pooling layer. The first two layers also follow normalization using local response normalization. The first Convolutional Layer contains 96 filters of 7×7 pixels, the second Convolutional Layer contains 256 filters of 5×5 pixels, The third and final Convolutional Layer contains 384 filters of 3×3 pixels. Finally, two fully-connected layers are added, each containing 512 neurons.

net_illustration

Dataset Preparation

Download

The dataset used for training is UTKFace but filter to get only Asian people for the project’s purpose. Full UTKFace dataset can be download at UTKFace

To download UTKFace AsianOnly:

  1. ./download.sh

Split train/test and oversampling train set

  1. python3 build_dataset.py

Note: the split ratio is 0.8. After spliting into train/test set, the augmentation process is then implemented by flipping and adding noise to original images to balance number of sample between age classes.

  1. Number of image per age class:
  2. 0-9 10-19 20-29 30-39 40-49 50-59 60-69 70-79 80-120
  3. --------------------------------------------------------------
  4. 734 78 1066 423 126 95 76 67 82
  5. Number of image per gender class:
  6. Male Female
  7. --------------
  8. 1260 1487
  9. AFTER OVERSAMPLING:
  10. Number of image per age class:
  11. 0-9 10-19 20-29 30-39 40-49 50-59 60-69 70-79 80-120
  12. --------------------------------------------------------------
  13. 1066 1066 1066 1065 1066 1065 1066 1065 1066
  14. Number of image per gender class:
  15. Male Female
  16. --------------
  17. 5690 3901

Create lmdb - Make mean file

  1. ./create_lmdb.sh
  2. ./create_mean.sh

Train and Test

Train

Train AgeNet

  1. ./train_AgeNet.sh

Train GenderNet

  1. ./train_GenderNet.sh

Test

Test AgeNet

  1. ./test_AgeNet.sh

Test GenderNet

  1. ./test_GenderNet.sh

Test result

AgeNet

  1. Accuracy: 66.5%, 457/687 corrects
  2. Confusion matrix:
  3. Actual\Predict 0-9 10-19 20-29 30-39 40-49 50-59 60-69 70-79 80-120
  4. -----------------------------------------------
  5. 0-9 178 2 7 2 0 0 0 0 2
  6. 10-19 4 2 9 3 1 0 0 0 0
  7. 20-29 1 2 214 44 2 2 2 2 0
  8. 30-39 2 2 50 37 8 5 1 2 1
  9. 40-49 0 1 6 10 8 2 1 0 0
  10. 50-59 0 0 1 4 3 3 5 1 0
  11. 60-69 2 0 3 2 0 3 3 3 0
  12. 70-79 0 0 1 0 0 4 8 4 3
  13. 80-120 1 0 0 2 0 0 2 6 8

GenderNet

  1. Accuracy: 85.2%, 585/687 corrects
  2. Confusion matrix:
  3. Actual\Predict Male Female
  4. -----------------------------------------------
  5. Male 267 53
  6. Female 49 318

Convert to NCS graph

This script compiles AgeNet and GenderNet caffe models into NCS graphs. It also converts mean file.

  1. ./compile2Movidius.sh

Run inference

  1. python3 run_inference.py --mean_file age_gender_mean.npy --image_path image/test_0.png

Citation

  1. @inproceedings{LH:CVPRw15:age,
  2. author = {Gil Levi and Tal Hassner},
  3. title = {Age and Gender Classification Using Convolutional Neural Networks},
  4. booktitle = {IEEE Conf. on Computer Vision and Pattern Recognition (CVPR) workshops},
  5. month = {June},
  6. year = {2015},
  7. URL = {\url{https://osnathassner.github.io/talhassner/projects/cnn_agegender}}
  8. }