Skip to content

๐Ÿง  AI-powered facial analysis: Detect age, gender & ethnicity from images using deep learning CNN models. Multi-task learning with TensorFlow/Keras! โœจ

License

Notifications You must be signed in to change notification settings

jonathanrao99/Gender-and-Age-Detection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

5 Commits
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ‘ฅ Gender and Age Detection with Deep Learning

Python TensorFlow Keras Jupyter License

Detect age and gender from facial images like a pro! ๐Ÿš€

Advanced deep learning models for facial attribute analysis with style


๐ŸŽฏ What's This?

A powerful deep learning project that analyzes facial images to predict age, gender, and ethnicity. Think of it as your personal facial analysis AI! ๐Ÿง 

โœจ What You Get

  • ๐ŸŽฏ Multi-task learning (Age, Gender, Ethnicity)
  • ๐Ÿง  Deep CNN architecture with TensorFlow/Keras
  • ๐Ÿ“Š Comprehensive data analysis and visualization
  • ๐Ÿ”„ Data augmentation for better model performance
  • ๐Ÿ“ˆ Training metrics and model evaluation
  • ๐Ÿ’พ Model serialization for deployment
  • ๐ŸŽจ Beautiful visualizations with Plotly
  • โšก Optimized training with callbacks

๐Ÿš€ Quick Start

# 1. Clone it
git clone <your-repo-url>
cd Gender-and-Age-Detection

# 2. Install dependencies
pip install tensorflow pandas numpy matplotlib seaborn plotly scikit-learn

# 3. Run the notebook!
jupyter notebook "Age Detection.ipynb"

That's it! ๐ŸŽ‰


๐ŸŽฎ How to Use

Option 1: Jupyter Notebook (Recommended)

jupyter notebook "Age Detection.ipynb"

Perfect for interactive development and analysis

Option 2: Google Colab

# Upload the notebook to Google Colab
# Enable GPU runtime for faster training

For cloud-based training with GPU acceleration

Option 3: Command Line Training

# Run specific cells or convert to Python script
python -c "exec(open('Age Detection.ipynb').read())"

For automated training pipelines


๐Ÿ“Š Sample Output

๐Ÿ“Š Dataset Statistics:
- Total samples: 23,705 faces
- Age range: 1-116 years
- Gender distribution: Male/Female balanced
- Ethnicity classes: 5 categories

๐Ÿง  Model Performance:
- Gender accuracy: ~52.6%
- Age accuracy: Varies by age group
- Ethnicity accuracy: ~43.2%

๐Ÿ“ˆ Training Metrics:
- Batch size: 64
- Epochs: 100 (with early stopping)
- Learning rate: 0.001 (adaptive)

๐Ÿ› ๏ธ What's Inside

Gender-and-Age-Detection/
โ”œโ”€โ”€ ๐Ÿ‘ฅ Age Detection.ipynb          # Main analysis notebook
โ”œโ”€โ”€ ๐Ÿง  age.h5                      # Trained age model
โ”œโ”€โ”€ ๐Ÿ‘ค gender.h5                   # Trained gender model
โ”œโ”€โ”€ ๐Ÿ“Š age_gender.csv              # Processed dataset
โ”œโ”€โ”€ ๐Ÿ“š README.md                   # This file
โ””โ”€โ”€ ๐Ÿ“„ LICENSE                     # MIT License

๐ŸŽจ Features

๐Ÿ“Š Data Analysis & EDA

  • Comprehensive dataset exploration
  • Age distribution analysis
  • Gender and ethnicity balance check
  • Missing value detection
  • Statistical summaries

๐Ÿง  Deep Learning Models

  • Multi-task CNN architecture
  • Convolutional layers with batch normalization
  • Dropout layers for regularization
  • Dense layers for classification
  • Softmax/Sigmoid activations

๐Ÿ”„ Data Preprocessing

  • Image normalization (0-1 scaling)
  • Data augmentation (rotation, zoom, shift)
  • Train-test splitting (70-30)
  • One-hot encoding for categorical variables

๐Ÿ“ˆ Training & Evaluation

  • Early stopping to prevent overfitting
  • Learning rate reduction on plateau
  • Confusion matrix analysis
  • Accuracy metrics for each task
  • Model serialization (.h5 format)

๐ŸŽจ Visualizations

  • Age distribution histograms
  • Gender balance pie charts
  • Ethnicity distribution bar plots
  • Training curves with Plotly
  • Confusion matrices heatmaps

๐ŸŽช Fun Features

  • ๐ŸŽฒ Multi-task learning (3 models in 1)
  • ๐ŸŽฎ Interactive visualizations with Plotly
  • ๐Ÿฅš Hidden data insights
  • ๐ŸŽจ Beautiful plotting with seaborn
  • ๐ŸŽฏ Real-time training progress
  • ๐ŸŽช Comprehensive model evaluation

๐Ÿ› Troubleshooting

Problem: ModuleNotFoundError: No module named 'tensorflow' Solution: pip install tensorflow pandas numpy matplotlib seaborn plotly scikit-learn

Problem: GPU not detected Solution: Install GPU version: pip install tensorflow-gpu

Problem: Memory issues during training Solution: Reduce batch size or use data generators

Problem: Slow training Solution: Enable GPU runtime in Colab or use cloud instances


๐Ÿ”ง Technical Highlights

โœ… What I Built

  • Multi-task CNN for simultaneous prediction
  • Data augmentation pipeline for robustness
  • Comprehensive EDA with statistical analysis
  • Model evaluation with multiple metrics
  • Production-ready model serialization
  • Scalable architecture for large datasets

๐Ÿง  Model Architecture

  • Input Layer: 48x48x1 grayscale images
  • Conv2D Layers: Feature extraction
  • MaxPool2D: Dimensionality reduction
  • BatchNormalization: Training stability
  • Dropout: Regularization
  • Dense Layers: Classification heads

๐Ÿ“Š Dataset Features

  • Age: 1-116 years (continuous)
  • Gender: Male/Female (binary)
  • Ethnicity: 5 categories (multi-class)
  • Images: 48x48 grayscale pixels

๐Ÿ“ˆ Performance Metrics

  • Gender Accuracy: ~52.6%
  • Age Accuracy: Varies by age group
  • Ethnicity Accuracy: ~43.2%
  • Training Time: ~30-60 minutes (CPU)
  • Model Size: ~10-15 MB per model
  • Inference Speed: Real-time capable

๐Ÿค Contributing

  1. Fork it ๐Ÿด
  2. Create a branch ๐ŸŒฟ
  3. Make changes โœ๏ธ
  4. Submit PR ๐Ÿš€

Ideas welcome! ๐Ÿ’ก


๐Ÿ“Š Data Sources

  • Primary Dataset: Age, Gender, and Ethnicity Face Data (CSV)
  • Source: Kaggle Dataset by Nipun Arora
  • Size: 23,705 facial images
  • Format: 48x48 grayscale pixels
  • Attributes: Age, Gender, Ethnicity

โš ๏ธ Disclaimer

For educational and research purposes! This project analyzes facial images for age, gender, and ethnicity prediction. Always respect privacy and ensure proper consent when using facial analysis technology! ๐Ÿค–


๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


๐ŸŒŸ Star the Repository

If you find this project helpful, please give it a โญ on GitHub!

GitHub stars

๐Ÿ“ž Connect & Support

GitHub LinkedIn Buy Me a Coffee


Made with โค๏ธ and โ˜• by Jonathan Thota

Analyzing faces, one pixel at a time! ๐Ÿ‘ฅ

About

๐Ÿง  AI-powered facial analysis: Detect age, gender & ethnicity from images using deep learning CNN models. Multi-task learning with TensorFlow/Keras! โœจ

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published