Skip to content

Face Detection and Gender and Age Classification using Keras

License

Notifications You must be signed in to change notification settings

grausof/AgeGenderEmotion

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Yolo Keras Face Detection

Implement Face detection, and Age and Gender Classification using Keras.

(image from wider face dataset)

Overview

Functions

Face Detection

Age and Gender Classification

Requirements

Keras2 (Tensorflow backend)

OpenCV

Python 2.7

Darknet (for Training)

Perl (for Training)

Test

Download Pretrained-Model

python download_model.py

Predict from Camera Image

Here is a run using pretrained model .

python agegender_demo.py

Train

Install

Keras

pip install keras

Darknet

Download Darknet and put in the same folder.

https://github.com/pjreddie/darknet

Face Detection (FDDB)

Create dataset

Download fddb dataset (FDDB-folds and originalPics folder) and put in the dataset/fddb folder.

http://vis-www.cs.umass.edu/fddb/

Create datase/fddb/FDDB-folds/annotations_darknet folder for darknet.

perl annotation_fddb_darknet.pl

Preview converted annotations.

python annotation_view.py fddb

FDDB dataset overview

Train using Darknet

Here is a training using YoloV2.

cd darknet

./darknet detector train data/face-one-class.data cfg/yolov2-tiny-train-one-class.cfg

Test using Darknet

Here is a test.

./darknet detector demo data/face-one-class.data cfg/yolov2-tiny-train-one-class.cfg backup-face/yolov2-tiny-train-one-class_32600.weights -c 0

Training Result

http://www.abars.biz/keras/yolov2-tiny-one-class.cfg

http://www.abars.biz/keras/yolov2-tiny-train-one-class_32600.weights

Convert to Keras Model

Download YAD2K

https://github.com/allanzelener/YAD2K

This is a convert script.

python3 yad2k.py yolov2-tiny-train-one-class.cfg yolov2-tiny-train-one-class_32600.weights yolov2_tiny-face.h5

This is a converted model.

http://www.abars.biz/keras/yolov2_tiny-face.h5

Age and Gender classification

Create Dataset

Use AdienceBenchmarkOfUnfilteredFacesForGenderAndAgeClassification dataset

Download AdienceBenchmarkOfUnfilteredFacesForGenderAndAgeClassification dataset (agegender folder) and put in the dataset/agegender folder.

https://www.openu.ac.il/home/hassner/Adience/data.html#agegender

Create dataset/agegender/annotations for keras.

perl annotation_agegender_keras.pl

Use IMDB-WIKI dataset

Download IMDB-WIKI dataset (Download faces only 7gb) and put in the dataset/imdb_crop folder.

https://data.vision.ee.ethz.ch/cvl/rrothe/imdb-wiki/

Create dataset/agegender/annotations for keras.

python annotation_imdb_keras.py

Note : The age labels in the IMDB-WIKI dataset are noisy.

yu4u/age-gender-estimation#15

Use UTKFace dataset

Download UTKFace dataset and put in the dataset/imdb_crop folder.

https://susanqq.github.io/UTKFace/

Create dataset/agegender/annotations for keras.

python annotation_utkface_keras.py

Train using Keras

Install keras-squeezenet

https://github.com/rcmalli/keras-squeezenet

Run classifier task using keras.

python agegender_train.py age101 squeezenet

python agegender_train.py gender squeezenet

Test using Keras

Test classifier task using keras.

python agegender_predict.py age101 squeezenet

python agegender_predict.py gender squeezenet

Training result

Age101 (IMDB)

http://www.abars.biz/keras/agegender_age101_squeezenet.hdf5

Gender (IMDB)

http://www.abars.biz/keras/agegender_gender_squeezenet.hdf5

Related Work

https://github.com/dannyblueliu/YOLO-Face-detection

https://github.com/oarriaga/face_classification

https://github.com/yu4u/age-gender-estimation

About

Face Detection and Gender and Age Classification using Keras

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 77.6%
  • Perl 21.9%
  • Batchfile 0.5%