Git Product home page Git Product logo

agendernet's Introduction

Age and Gender Predictor

Update from old repo

Environment Setup

Docker with GPU support

Manually

Using python 3.5, core libraries are :

  • dlib
  • tensorflow
  • keras
  • opencv
  • mxnet

Datasets

Datasets are saved in data/ directory

Age Distribution

dist

Preprocess (for training)

For complete instruction, check on data/ directory

  • For IMDB and Wiki dataset remove any unsual data from its .mat file with following characteristics:
    • Age is below 0 and above 100
    • Face score is NaN
    • Second face score is exist
    • Missing gender label
  • Manual cleansing on IMDB-Wiki data with age 0-20 using tools
  • Detect and align face using dlib with margin 0.4 (following [1] margin size)
  • Remove image which has no face detected or the face is unclear so it's not detected
  • Data normalization following each model requirement (in model's prep_image method)

Model

Here we use 3 model

InceptionV3 and MobileNetV2

We use InceptionV3 and MobileNetV2 from keras-application without it's classifier output and modify it to have 2 output layer. One for gender prediction with 2 nodes and another for age prediction with 101 nodes (represent age 0-100). We treat age prediction as multiclass classification problem with it's output calculated from softmax regression as in [1] reference

SSR-Net

We follow default SSR-Net architecture with some modification. At the top we have 1 classifier block which then feed into 2 classifier block. In SSR-Net, we treat prediction as regression problem for both age and gender

Train

For InceptionV3 and MobileNetV2 we used pretrained weight from keras-application which was trained on ImageNet dataset. So, we do transfer learning on InceptionV3 and MobileNetV2. And, training from scratch on SSR-Net Training was done in AWS P3 instance with Nvidia Tesla V100 with 10 fold cross-validation and 50 epoch each to check for model consistency and get weight file with best metrics For each model, following input size is used:

  • InceptionV3 : 140 x 140 px
  • MobileNetV2 : 96 x 96 px
  • SSR-Net : 64 x 64 px Here is the training history

InceptionV3

log inceptionv3

MobileNetV2

log mobilenetv2

SSR-Net

log ssrnet

Evaluation

For model performance evaluation, we use UTKFace and FGNET dataset. Here we also try age and gender model from InsightFace project which was build on ResNet50 architecture. We also crawl some Indonesian artist faces from wikipedia with total of 51 validated images Here is the result (model in top position hold the best score)

UTKFace Dataset

UTKFace Gender Acc Bar UTKFace Age MAE

FGNET Dataset

FGNET Age MAE

Indonesian Face

Indonesia Gender Acc Bar Indonesia Age MAE

Inference time - performance score

inference

Demo Video Stream

Use stream.py to try the models. SORT tracker is integrated to add age and gender prediction smoothing for prediction result Usage :

usage: video.py [-h] [-s SRC]

optional arguments:
  -h, --help         show this help message and exit
  -s SRC, --src SRC  Video stream source, default will be webcam (0)

References and Acknowledgments

This project is part of my internship program at Nodeflux as data scientist from July - August, 2018

  1. Rothe R, Timofte R, Van Gool L. Dex: Deep expectation of apparent age from a single image[C]//Proceedings of the IEEE International Conference on Computer Vision Workshops. 2015: 10-15.
  2. Rothe R, Timofte R, Van Gool L. Deep expectation of real and apparent age from a single image without facial landmarks[J]. International Journal of Computer Vision, 2016: 1-14.
  3. [IJCAI18] SSR-Net: A Compact Soft Stagewise Regression Network for Age Estimation
  4. yu4u/age-gender-estimation Keras implementation of a CNN network for age and gender estimation
  5. deepinsight/insightface Face Recognition Project on MXNet
  6. abewley/sort Simple, online, and realtime tracking of multiple objects in a video sequence

agendernet's People

Contributors

dandynaufaldi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

agendernet's Issues

please help me .I got an error:KeyError: 'epoch'

Traceback (most recent call last):
File "/home/hxl/project/Agendernet/train.py", line 166, in
main()
File "/home/hxl/project/Agendernet/train.py", line 138, in main
model),
KeyError: 'epoch'

python train.py --model inceptionv3
136callbacks = [
137 ModelCheckpoint(
138 "train_weight/{}-{epoch:02d}-{val_loss:.4f}-{val_gender_prediction_acc:.4f}-{val_age_prediction_mae:.4f}.h5".format(
139 model),
140 verbose=1, save_best_only=True, save_weights_only=True),
141 CSVLogger('train_log/{}-{}.log'.format(MODEL, n_fold))]

pre-trained model

first,thanks for your great job.if i could use your pre-trained model.thanks for your reply!

README.md update

Hi there,

(wonderful project by the way) So I was wondering if you could update the readme to add steps to reproduce your results. despite the script being well organized thus far I've been unable to reproduce your work. My guess is that I'm missing a step

thank you

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.