A real-time computer vision system that detects age range, gender, confidence scores, and edge density from live webcam feed or static images — built using OpenCV DNN with pre-trained Caffe models.
Real detections from webcam and static images:
| Demo 1 | Demo 2 | Demo 3 |
|---|---|---|
![]() |
![]() |
![]() |
| Male, 21–24 years · 100% conf | Male, 21–24 years · 100% conf | Male, 21–24 years · 100% conf |
| Child Detection | Senior Detection |
|---|---|
![]() |
![]() |
| Female, 4–6 years (Child) · 100% conf | Male, 60+ years (Senior) · High Confidence |
The system runs a 3-stage DNN pipeline on every frame:
- Face Detection — SSD ResNet10 model detects faces with bounding boxes
- Age Classification — Classifies face into one of 9 age buckets
- Gender Classification — Predicts Male/Female with confidence score
Additionally computes edge density per face using Canny edge detection — a measure of facial texture detail.
| Feature | Details |
|---|---|
| 🎥 Real-time webcam | Live detection at 5–7 FPS |
| 🖼️ Static image mode | Detect from any image file |
| 📹 Video file mode | Process entire video files |
| 🎯 Age classification | 9 age buckets from infant to senior |
| 👤 Gender detection | Male/Female with confidence % |
| 📊 Edge density | Canny-based facial texture metric |
| 💾 Screenshot save | Press 's' to save any frame |
| 🖥️ FPS counter | Real-time frame rate display |
Age-Prediction/
├── app.py # Main entry point (CLI)
├── src/
│ ├── __init__.py
│ ├── detector.py # Core DNN detection engine
│ ├── webcam.py # Real-time webcam application
│ ├── image_predictor.py # Static image predictor
│ ├── utils.py # Edge density, labels, banner
│ └── download_models.py # Auto model downloader
├── models/
│ ├── README.md # Model download instructions
│ ├── deploy.prototxt # Face detector config (download)
│ ├── age_deploy.prototxt # Age model config (download)
│ └── gender_deploy.prototxt # Gender model config (download)
├── outputs/
│ ├── demo_webcam_1.jpeg # Real webcam output screenshot
│ ├── demo_webcam_2.jpeg
│ ├── demo_webcam_3.jpeg
│ ├── demo_image_child.jpeg # Child detection result
│ └── demo_image_senior.jpeg # Senior detection result
├── tests/
│ └── test_detector.py # Unit tests
├── requirements.txt
├── .gitignore
└── README.md
git clone https://github.com/NandithKumar/Age-prediction.git
cd Age-predictionpip install -r requirements.txtpython src/download_models.pypython app.py --mode webcam- Press
sto save a screenshot - Press
qto quit
python app.py --mode image --input path/to/image.jpgpython app.py --mode video --input path/to/video.mp4 --output result.mp4Input Frame (Webcam / Image / Video)
│
▼
Face Detection (SSD ResNet10)
→ Bounding boxes + face confidence %
│
▼
Face Crop + Padding (20px)
│
┌─────┴──────┐
▼ ▼
Age Net Gender Net
(9 buckets) (Male/Female)
│ │
└─────┬──────┘
▼
Edge Density (Canny)
│
▼
Annotated Frame Output
| Bucket | Category |
|---|---|
| 0–2 | Infant |
| 4–6 | Child |
| 8–12 | Child |
| 15–20 | Teenager |
| 21–24 | Young Adult |
| 25–32 | Young Adult |
| 38–43 | Middle-Aged |
| 48–53 | Middle-Aged |
| 60–100 | Senior |
| Component | Technology |
|---|---|
| Language | Python 3.8+ |
| Computer Vision | OpenCV 4.7+ |
| Deep Learning | OpenCV DNN Module |
| Face Detection | SSD ResNet10 (Caffe) |
| Age/Gender | GilLevi Caffe Models |
| Edge Analysis | Canny Edge Detection |
python -m pytest tests/Paladugu Nandith Kumar
- 🎓 B.Tech CSE (AI & ML) — RGMCET, Kadapa
- 🌐 Portfolio
- 📧 nandith1411@gmail.com
MIT License




