This project is designed to predict the approximate age of individuals based on images using computer vision techniques. The solution was built for a network supermarket "Khleb-Sol," aiming to analyze customer age demographics for targeted recommendations and ensuring cashier compliance in age-restricted sales.
The primary objective is to develop a machine learning model capable of accurately predicting the age of individuals in images. The model leverages a convolutional neural network (CNN) to learn from a dataset of annotated images with real ages, aiming for a Mean Absolute Error (MAE) of less than 8 on the validation set.
-
Dataset:
- The dataset is based on the "ChaLearn Looking at People" collection and contains images and real ages.
- It consists of 7,591 images in the
/final_files
folder, with labels stored inlabels.csv
.
-
Data Exploration:
- Analyzed distribution of ages in the dataset.
- Identified potential data imbalance, with a higher representation of younger individuals compared to older ones.
-
Preprocessing:
- Resizing images to a fixed size of 150x150 pixels.
- Data augmentation techniques applied to introduce variability and improve model robustness.
-
Model Architecture:
- A pre-trained ResNet50 model was used as the backbone with additional dense layers.
- Fine-tuning involved unfreezing the top layers of ResNet and reducing the learning rate to improve generalization.
-
Training and Validation:
- The model achieved MAE on training data: 3.64 and MAE on validation data: 6.94, meeting the project's accuracy goals.
- Dropout layers were used to prevent overfitting, and data augmentation helped improve model performance on unseen images.
The project requires the following libraries:
tensorflow
pandas
numpy
matplotlib
-
Clone Repository:
git clone <repository_link>
-
Install Dependencies:
pip install -r requirements.txt
-
Run the Training Script: To train the model, run:
python train.py
-
Inference:
- The model can predict the age of a person in an image by running:
python inference.py --image_path <path_to_image>
- The model demonstrates a lower MAE on the training dataset than on the validation set, indicating a balanced training process with room for improvement in generalization.
- A clear age distribution bias towards younger individuals was noted, suggesting potential improvements by rebalancing the dataset or focusing on data augmentation for underrepresented age groups.
- Address Data Imbalance: Implement synthetic oversampling or targeted data augmentation for older age groups.
- Enhanced Preprocessing: Improve image quality or remove background noise to focus more on facial features.
- Hyperparameter Tuning: Explore further optimizations in learning rate, optimizer selection, and network depth.
This project is licensed under the MIT License. See LICENSE
for details.
- ChaLearn Looking at People: Dataset used for model training.
- Yandex Compute Cloud: GPU resources for training.