This project demonstrates a Convolutional Neural Network (CNN) model designed to predict both age and gender from facial images. The model was built using the Keras Functional API, a flexible approach that allows for complex model architectures with multiple inputs and outputs.
Key Features
Multi-task Learning: The model is a multi-task learning system that performs two distinct types of supervised predictions simultaneously:
Gender Classification: Predicts gender from a facial image.
Age Regression: Predicts the age of the person in the image.
Dataset: The model was trained using an Age, Gender (Face Data) CSV dataset.
Data Preprocessing: The pixel data, initially stored as a string object, was converted into a numerical array and normalized to improve the model's training efficiency. The images were also reshaped to a 48x48 pixel, single-channel format.
Model Architecture: The CNN architecture consists of several layers:
Input Layer: Takes in the preprocessed image data.
Hidden Layers: A series of Conv2D and MaxPooling2D layers extract features from the images, followed by Flatten and Dense layers for further processing.
Output Layers: Two separate dense layers handle the different prediction tasks:
A dense layer with a sigmoid activation function for gender classification.
A dense layer with a linear activation function for age regression.
Training and Evaluation: The model was compiled with specific loss functions and metrics for each task (binary_crossentropy and accuracy for gender, and mse for age). It was trained for 100 epochs with an EarlyStopping callback to prevent overfitting. The model's performance was evaluated on a validation set to ensure its effectiveness.
Prediction: After training, the model can predict the age and gender from new facial images. A visual subplot of random images and their corresponding predictions showcases the model's ability to accurately perform both tasks.