Keras implementation of EfficientNet model for age and gender estimation from the paper EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks
Contains code to build the EfficientNets B0-B7 from the paper, and includes weights for configurations.
In this paper, I used EfficientNets B4 model for estimation.
Facial details analysis play an important role in understanding human behavior. Detail such as age and gender are the key indicator in analyzing characteristic of a person.
In this paper, we propose an architecture of EfficientNets which can jointly learn representations for three tasks: face detection, gender and age classification.
- Python 3.7+
- EfficientNets library (!!! important: pip install -U efficientnet==0.0.4)
- OpenCV2
- Keras
- Numpy
This is a Keras implementation of a EfficientNet model for estimating age and gender from a face image. In this paper, I use the IMDB-WIKI dataset for training and the UTKFace dataset for testing, which consist of age and gender information
Dataset consist of most popular 100,000 actors as listed on the IMDb website and (automatically) crawled from their profiles date of birth, name, gender and all images related to that person. With the additional information from Wikipedia.
IMDB-WIKI age data have over 101 age classes, we want to create a model that is practical for real world application
There are some images in the data are mis labeled (some with negative age), we have manually check and reorganize the data. The datasets is processed into 5 classes of age and 2 classes of gender: age_branch(1-13, 14-23, 24-39, 40-55, 56-85), gender_branch(0: Male, 1: Female) based on facial feature of each age segment
In this model, we used 32000 images for training.
-
Firstly, dowload the datasets from the IMDB-WIKI dataset
-
Secondly, filter out noise data and serialize images and labels for training into .mat file. Please click data folder to run create_db.py
UTKFace dataset is a large-scale face dataset with long age span (range from 0 to 116 years old). The dataset consists of over 20,000 face images with annotations of age, gender, and ethnicity. Don't use images which have age from 86-100. So the datasets reduce into 19000 face images
- Dowload the datasets from the UTKFace dataset. UTKFace.tar.gz can be downloaded from Aligned&Cropped Faces in Datasets section
- Run file data/create_db.py
- To increase accuracy, we used MTCNN to crop the faces and remove non-face image.
- To conveniently moving dataset to Google Drive (for training in Google Collab). We encode all dataset to ‘.npy’ format (Numpy array) instead of uploading every images. All the datasets are decoded into images before training the model.
- Please see age_gender_estimation.ipynb
Branch | Train | Val | Test |
---|---|---|---|
AGE |
66.71% | 61.95% | 62% |
GENDER |
96.74% | 94.13% | 91.76% |
python3 inference_img.py
- Mingxing Tan and Quoc V. Le. EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks. ICML 2019. Arxiv link: https://arxiv.org/abs/1905.11946.'
- https://github.com/qubvel/efficientnet