Convolutional Neural Network (CNN).
This repository contains a source code of a deep learning network built with TensorFlow and Keras to classify gender and estimate age.
Dataset
UTKFace. Large Scale Face Dataset
- Download the file containing Aligned&Cropped Faces archive. The repository contains 23,708 images with annotations encoded in the filename. All images have 200*200 px resolution.
- Unpack the contents into the
./src/all_images
folder.
Example input images with actual gender and age:
Application
- Create and activate a virtual environment.
- Install project dependencies with
pip install -r requirements.txt
- Run the
start.py
file. - When running for the first time, select option 1 to split the images into train, validation and test subfolders. There is no need to repeat this operation every time.
- The main menu includes an option to check if your system supports GPU training.
- A pre-trained model is included in the
/.output/models
folder. Feel free to overwrite or delete it.
CNN Architecture
Performance
The file history/age_gender_model.csv
contains the training history.
Age - Mean Average Error (MAE)
Gender - Accuracy
Gender - Loss
Loss
Inference
Run test the model
option from main menu to load a few images and predict age and gender.
GPU Support
Tune down the batch_size
hyperparameter if your GPU runs out of memory.
Tensorflow version that currently supports GPU with the latest CUDA / CUDNN.
pip install tf-nightly-gpu
Graphviz
You might require to install the Graphviz plotting library.
If you encounter an issue with plotting in your IDE, refer to this [Stack Overflow answer](Graphvis issue with plotting](https://stackoverflow.com/a/62611005/6666457)
Type in the terminal with admin rights:
dot -c