- Overview
- Business Problem
- Dataset
- Exploratory Data Analysis (EDA)
- Modeling Approach
- Results & Model Performance
- Key Insights & Business Impact
- Next Steps & Potential Improvements
- How to Use
- Connect With Me
This project explores computer vision techniques to predict a person’s age from images. The goal is to determine whether machine learning can help a supermarket chain ensure compliance with alcohol sales laws by verifying a customer's age at checkout.
Good Seed, a supermarket chain, wants to implement an automated system to prevent underage alcohol sales. They aim to:
- Use computer vision to estimate a customer’s age from a photo.
- Train a convolutional neural network (CNN) to make accurate predictions.
- Evaluate the feasibility of AI-powered age verification.
The dataset is sourced from ChaLearn Looking at People and contains:
- Images: Stored in the
final_files/
folder. - Labels: A CSV file (
labels.csv
) with:file_name
→ Image filename.real_age
→ True age of the individual.
Given the large dataset size (~7,600 images), data generators were used for efficient loading.
- Age distribution: The dataset covers a broad age range but has more images of younger individuals.
- Visual inspection: Sample images confirmed variability in lighting, angles, and expressions, impacting model accuracy.
The model uses a pretrained ResNet50 architecture with fine-tuning:
- Base Model: ResNet50 (pretrained on ImageNet).
- Additional Layers:
- GlobalAveragePooling2D for feature extraction.
- Dense layer with ReLU activation.
- Output layer predicting a single continuous value (age).
- Loss Function: Mean Squared Error (MSE).
- Optimizer: Adam (learning rate: 0.0005).
The model was trained on GPU using data augmentation:
- Horizontal flips and rotations to improve generalization.
- Mini-batches for memory efficiency.
- Early stopping to prevent overfitting.
Epoch | Train MAE | Validation MAE |
---|---|---|
1 | 7.43 | 8.49 |
5 | 5.59 | 8.21 |
10 | 4.14 | 6.96 |
15 | 3.67 | 6.78 |
20 | 3.17 | 7.65 |
- The final MAE (Mean Absolute Error) = 7.1 years.
- The model performs well for middle-aged individuals but struggles with extreme age groups.
- Validation loss fluctuated, suggesting further tuning is needed.
- Moderate accuracy: The model can estimate age within ~7 years, making it unreliable for strict legal compliance.
- Practical applications: Useful for pre-screening but requires human verification for final decisions.
- Challenges:
- Poor performance on very young & elderly individuals.
- External factors (lighting, facial expressions) impact predictions.
- Use AI as an assistive tool, not a standalone verification system.
- Combine with ID scanning for more reliable validation.
- Train on a more balanced dataset with improved age representation.
- Fine-tune model hyperparameters to reduce MAE.
- Experiment with deeper architectures (EfficientNet, Vision Transformers).
- Incorporate additional facial features for better predictions.
- Train on a larger, more diverse dataset to improve generalization.
git clone https://github.com/rhi-222/human-age-prediction.git
pip install tensorflow keras matplotlib numpy pandas seaborn
- Open
[updated]HumanAge(ComputerVision).ipynb
in Jupyter Notebook or Google Colab. - Execute the notebook to preprocess images, train the model, and evaluate predictions.
- Email: [email protected]
- LinkedIn: linkedin.com/in/rhiannonfilli