Note
This repository is currently provided primarily for research and educational purposes. As such, the model and code structure are my own design and may not always yield optimal results. For production-level applications, I recommend exploring more modern and efficient architectures specifically tailored for face embedding tasks. Thanks. This repository may be rewritten in the future to incorporate such improvements.
This repository represents a deep learning project aimed at estimating age and predicting gender using the UTKFace dataset available on Kaggle along with MTCNN (Multi-task Cascaded Convolutional Networks) for face detection. The primary objective of this project is to accurately predict the age and gender of individuals depicted in images in the best case scenario.
This project comprises two main sections: "Facenet" and "AgeNet" (custom names).
The "Facenet" section employs the Multi-task Cascaded Convolutional Networks (MTCNN) to detect and extract facial regions present within images.
The "AgeNet" section consists of three distinct components:
-
Gender Classification Network (VGG-Face): Utilizing the powerful VGG-Face architecture, this network is designed to classify the gender of individuals within the detected facial regions. Its deep learning capabilities enable precise gender identification based on facial features.
-
Age Range Classification Network: Instead of directly predicting the exact age of each individual in the image, we will predict age ranges. This approach reduces the output complexity, making the classification more efficient.
-
Age Estimation Network: Unlike conventional age estimation approaches that predict only age ranges, this network refines age estimation further by predicting a specific age from within the age range determined in the previous step. This advanced approach provides more precise age predictions.
These three components are combined to form the "AgeNet" model, a comprehensive architecture for accurate age and gender prediction. The integration of multiple networks enables a more holistic understanding of facial attributes, resulting in enhanced prediction performance.
Visualizing the journey of model training is crucial to understanding its performance. Below, you'll find insightful line charts that represent accuracy and error metrics throughout the training process:
Analyzing the line charts yields the following insights:
-
Gender Classification Accuracy:
- Training Set: Achieved an impressive gender classification accuracy of 97%.
- Validation Set: Maintained a strong accuracy of 90% on unseen data.
-
Age Range Classification Accuracy:
- Training Set: Attained a satisfactory accuracy of 72% in classifying age ranges.
- Validation Set: Demonstrated robust performance with an accuracy of 65% on validation data.
-
Age Estimation Error:
- Training Set: Managed age estimation with a mean absolute error of 2.9 , showcasing reasonable precision.
- Validation Set: Maintained consistency with an estimated age error of 3.05.
The visual representation and detailed insights highlight the model's strengths and areas for potential enhancement. The exceptional gender classification accuracy reflects the model's competence in this task. Although age range classification and age estimation exhibit slightly lower accuracy and marginally higher errors, they offer opportunities for optimization and refinement.
- Clone the repository:
git clone https://github.com/manhcuong02/Pytorch-Age-Estimation.git
cd Pytorch-Age-Estimation
- Install the required dependencies:
pip install -r requirements.txt
-
Download weights of the pretrained model from ggdrive, and then add them to the 'weights' directory.
-
Run the age estimation script:
python3 predict.py --image-path your_path --weights weights_path --face-size 64 --device cpu --save-result --imshow
- Using the PyQt5 Interface (coming soon):
python3 main.py
Below are some promising outcomes of this project; however, there still exist inaccuracies in age and gender recognition in certain cases.