Skip to content

Computer Vision Model for Age Estimation from Facial Images

Notifications You must be signed in to change notification settings

schketik/neural_network_keras_resnet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

Age Prediction with Computer Vision

Project Overview

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.

Project Objective

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.

Project Structure

  • 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 in labels.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.

Requirements

The project requires the following libraries:

  • tensorflow
  • pandas
  • numpy
  • matplotlib

Usage

  1. Clone Repository:

    git clone <repository_link>
  2. Install Dependencies:

    pip install -r requirements.txt
  3. Run the Training Script: To train the model, run:

    python train.py
  4. Inference:

    • The model can predict the age of a person in an image by running:
    python inference.py --image_path <path_to_image>

Results and Observations

  • 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.

Future Improvements

  1. Address Data Imbalance: Implement synthetic oversampling or targeted data augmentation for older age groups.
  2. Enhanced Preprocessing: Improve image quality or remove background noise to focus more on facial features.
  3. Hyperparameter Tuning: Explore further optimizations in learning rate, optimizer selection, and network depth.

License

This project is licensed under the MIT License. See LICENSE for details.

Acknowledgments

  • ChaLearn Looking at People: Dataset used for model training.
  • Yandex Compute Cloud: GPU resources for training.