This project utilizes OpenCV and the Caffe framework to detect faces in real-time camera input and predict the gender and age of detected faces.
It is designed for students interested in computer vision and deep learning, providing a foundational structure and code for learning and experimentation.
-
Run the Main Script After downloading the required models and ensuring the directory structure matches the setup provided, no additional configuration is needed. Simply execute the following command :
python Gender_age_detector.py -
The program will activate the webcam, detect faces, and display age and gender predictions in real-time.
- Real-time Face Detection: Detect faces from live camera input using OpenCV.
- Gender Prediction: Predict the gender of detected faces using a pre-trained Caffe model.
- Age Prediction: Estimate the age of detected faces using a pre-trained Caffe model.
-
Gender_age_detector.py
- The main execution file for the project.
- Key functions:
- Processes real-time camera input using OpenCV.
- Detects faces and predicts their gender and age using Caffe models.
- Displays the results in real-time on the screen.
- Main libraries used:
OpenCV,NumPy.
-
age_train_val.prototxt
- Defines the training and validation network structure for the age prediction model in Caffe.
- Key contents:
- Specifies input data, network layers, and output data structure.
- Includes hyperparameters and settings for training.
-
deploy_age.prototxt
- Defines the deployment network structure for the age prediction model in Caffe.
- Key contents:
- A lightweight network structure used for testing or deploying the trained model.
-
gender_train_val.prototxt
- Defines the training and validation network structure for the gender prediction model in Caffe.
- Key contents:
- Similar to the age prediction file but optimized for gender classification.
-
deploy_gender.prototxt
- Defines the deployment network structure for the gender prediction model in Caffe.
- Key contents:
- A simplified network structure used for testing or deploying the trained gender prediction model.
-
style.xml
- GUI style configuration file.
- Key contents:
- Specifies visual styles such as bounding box colors and text fonts for displaying results.
-
Model Files (Download Required)
- age_net.caffemodel: Pre-trained model for age prediction (download required).
- gender_net.caffemodel: Pre-trained model for gender prediction (download required).
- Download locations are provided in the README or project source comments.
-
data/ (Expected Directory)
- Directory to store datasets for model training or testing.
- May require specifying the path in the project.
-
models/ (Expected Directory)
- Directory to store downloaded pre-trained model files.
- e.g.,
age_net.caffemodel,gender_net.caffemodel.
-
scripts/ (Expected Directory)
- Scripts for data preprocessing or model testing.
- e.g., dataset transformation, result visualization scripts.
-
Link: Caffe Model Zoo
Description: A repository of various deep learning models for experimentation with the Caffe framework.
Original Author: BVLC (Berkeley Vision and Learning Center) -
Link: Age and Gender Classification
Description: CNN-based age and gender classification models and resources created by Gil Levi.
Original Author: Gil Levi

