This model is using classification approach. Trained on 22k images scrapped from Wikipedia. IMDB dataset is also attached and can be used similarly.
General age prediction models uses regression based approach, that is sometimes not so accurate. Using the classification approach to find the age by not only using the max argument as we do. Instead, Taking consideration all the prediction values to predict apparent age of the person.
Similar to Age prediction - Gender Prediction was done by creating binary layer.
The model architecture is ready to be used for development and deployment weights are released.
The original work consumed face pictures collected from IMDB (7 GB) and Wikipedia (1 GB). You can find these data sets here. In this post, I will just consume wiki data source to develop solution fast. You should download faces only files.
Include logo/demo screenshot etc.
Built with
- Tensorflow 2.3.1
- Keras
- Numpy
Results are very satisfactory even though it does not have a good perspective. Marlon Brando was 48 and Al Pacino was 32 in Godfather Part I.
Researchers develop an age prediction approach and convert classification task to regression. They propose that you should multiply each softmax out with its label.
This is done faster using Numpy.
# Multiclass prediction
predictions = age_model.predict(test_x)
# Multiplying the weights of each prediction to class and summing it up
output_indexes = np.array([i for i in range(0, 101)])
actual_predictions = np.sum(predictions * output_indexes, axis = 1)
- Install the requirements
pip install -r requirements.txt
- Train the model or Download pretrained weights
- Run the evaluation on the image data by passing the path
- Download dataset and clean it - using
data_loading_cleaning.ipynb
notebook - Train the model which you are willing to use
- Evaluation script of the same model is there to infer your models
You can for the repository - create a pull request after making changes or can drop the issue by creating a new issue. It would be helpful for the community.
Sefik's Blog Post inspired me to build this project
https://sefiks.com/2019/02/13/apparent-age-and-gender-prediction-in-keras/
@InProceedings{Rothe-ICCVW-2015,
author = {Rasmus Rothe and Radu Timofte and Luc Van Gool},
title = {DEX: Deep EXpectation of apparent age from a single image},
booktitle = {IEEE International Conference on Computer Vision Workshops (ICCVW)},
year = {2015},
month = {December},
}