Age and Gender Detection
Age and Gender Detection
Age and Gender Detection
DETECTION
PROJECT REPORT
the degree Of
BACHELOR OF ENGINEERING
IN
COMPUTER SCIENCE AND ENGINEERING
1
CERTIFICATE
This is to certify that this report entitled “AGE AND GENDER DETECTION”
comprises literature review carried out by “Prince(1940020)” under the guidance of
Mr. Jatinder Pal Singh (Assistant Professor, Deptt. Of C.S.E) during the period
between Jan, 2023 to May, 2023 for B.E. degree in Computer Science and
Engineering from Sant Longowal Institute of Engineering and Technology (SLIET).
The results presented to this have not been submitted previously to this or any other
University for B.E. and any other degree.
Prince
GCS/1940020
This is to certify that the above statement made by the candidates is correct to the
best of my knowledge.
2
Acknowledgement
We, students of degree final year, Computer Science and Engineering have
successfully completed the project on “AGE AND GENDER DETECTION” at our
Institute SANT LONGOWAL INSTITUTE OF ENGINEERING AND
TECHNOLOGY, Sangrur, Punjab. We would like to thank our project guide Mr.
Jatinder Pal Singh Sir and all our teachers at SLIET for making the learning of latest
technology like python and, deep learning during this project period in fun and easy
way.
We would also like to thank Dr. Gurjinder Kaur, Project Coordinator of 2019 batch
to provide us this opportunity which helped us to make ourselves technically sound
which will help us in our career upliftment. We would like to extend our thanks to
Department of Computer Science and Engineering for providing us this wonderful
opportunity. It was a great learning experience. Thank you to all who helped us to
complete this project well within time.
THANK YOU.
3
Abstract
Predicting the gender and age of people from their facial images is still on-going and
active research issue. Many methods have been proposed by researchers to solve this
problem but still there is a deficiency between the requirements and veritable
performances.
In this project "Age and Gender Detection" aims to develop a model that can accurately
detect the age and gender of an individual from an image or live video. The system will
utilize deep learning algorithms and computer vision techniques to extract facial features
and analyze them to predict the age and gender of the person. The project will involve
collecting and preprocessing a large dataset of images, training and testing various deep
learning models, and evaluating the performance of the system. The proposed system
will have potential applications in various domains such as security systems, marketing,
and healthcare. The success of the project will be measured by the accuracy of the
predictions and the efficiency of the system.
4
List of Contents
1 Introduction 6
2 Problem Definition 7
3 Objectives 8
5 Result 28-29
6 Conclusion 30
7 Future Work 31
8 Reference 32
5
List of Figures
1 Dataset-1 12
2 Dataset-1 info() 12
3 Dataset-2 13
4 Dataset-2 info() 13
6 Hidden Layers 18
8 Imported Libraries 21
14 Table of Classes 28
6
Introduction
Age and gender, two of the key facial attributes, play a very foundational role in social
interactions, making age and gender estimation from a single face image an important task in
intelligent applications, such as access control, human-computer interaction, law
enforcement, marketing intelligence and visual surveillance, etc. The enhancing of raw
images that are received from the camera sources, from satellites, aircrafts and the pictures
captured in day-to-day lives is called image processing. The images have been
processed through many different techniques and calculations have been made on the
basis and analysis of the studies. There is a need of analyzing and studying the digitally
formed images. There are two main and very common steps followed for image
processing. The improvement of an image such that the resulted image is of greater
quality and can be used by other programs, is called image enhancement. Other
technique is the most sought after technique used for extraction of information from an
image. There is a division of the image into certain number of parts or objects so that the
problem is solved. This process is called segmentation. A neural network consists of
many simple and similar compressing elements. It is a system with input st and outputs.
There are a number of internal parameters called weights. An artificial neural network is
made of set of processing elements which are also known as neurons or nodes. These
nodes are interconnected. Training in ANN is done through the track of the examples.
Keywords: Facial Images; Gender Prediction; Age Prediction; pretrained model, transfer
learning.
7
Problem Statement
"Age and gender detection is a common computer vision problem that involves
predicting the age and gender of a person from an image or video. This problem has a
wide range of applications in various fields such as marketing, security, and healthcare.
Age and gender detection can be used to analyze customer demographics, monitor
security in public places, and diagnose medical conditions that affect different age and
gender groups differently. However, accurate age and gender detection is a challenging
problem due to variations in lighting, pose, and facial expressions, as well as the large
variations in appearance among individuals of the same age and gender. Therefore, the
goal of this project is to develop a deep learning model that can accurately predict the
age and gender of a person from an image or video, using data augmentation techniques
to increase the size and diversity of the training data."
8
Objective
The objective of age and gender detection is to develop a machine learning model that can
accurately predict the age and gender of a person based on their image or video input. The
main goals of this objective include:
1. Increasing accuracy: The primary objective of age and gender detection is to develop a
model that can accurately predict the age and gender of a person. This involves training
the model on a diverse dataset and optimizing it using appropriate loss functions and
evaluation metrics.
4. Enabling real-world applications: The ultimate objective of age and gender detection
is to develop a model that can be used in real-world applications, such as security
systems, marketing research, and entertainment. This requires ensuring that the model is
scalable, robust, and capable of handling different types of input data and use cases.
9
Methodology Used
Dataset Description
The Adience dataset is a benchmark dataset used for age and gender classification in
machine learning. The dataset contains 26,580 images of faces of people with ages
ranging from 0 to 100 years old. The images were collected from the internet and cover a
wide range of ethnicities, genders, and lighting conditions.
The dataset provides annotations for each image, including the age range and gender of
the person in the image. The age ranges are categorized into eight age groups: 0-2, 4-6,
8-12, 15-20, 25-32, 38-43, 48-53, and 60+. The gender is categorized as either male or
female.
The Adience dataset contains approximately 26,000 images of faces, with roughly equal
numbers of male and female subjects. The images are taken in various lighting
conditions, with different facial expressions and poses, and they are labeled with the
10
subject's age and gender. The dataset is divided into five subsets: training set, validation
set, test set, fold 0, and fold 1. The training, validation, and test sets are used for training,
validation, and testing the models, while the fold subsets are used for cross-validation.
The Adience dataset has been widely used for benchmarking the performance of age and
gender detection models and for developing new techniques for face recognition and
analysis. It has been used in a variety of research applications, including computer
vision, machine learning, and social sciences. The Adience dataset is a commonly used
dataset for age and gender detection tasks. It is a large-scale dataset that contains images
of faces of various ages and genders. The dataset was created by a team of researchers
from the University of California, San Diego and the University of Toronto, and it was
designed to be used for training and evaluating age and gender classification models.
The Adience dataset is freely available for research purposes, and it has been used in
various research studies to evaluate the performance of different age and gender
classification models.
11
Workflow
The workflow of the “Age and Gender Detection machine learning project” that it
processes the data(images) and extract the features and detect the age and gender of the
person in image.
1. Data collection: Collect a large dataset of face images with corresponding age and
gender labels. The Adience dataset is a commonly used dataset for this task.
2. Data preprocessing: Preprocess the face images to ensure they are in a consistent
format and resolution. This can include steps such as cropping the face, resizing the
image, and normalizing the pixel values.
3. Data augmentation: Augment the dataset with additional images to increase the
diversity of the training data. Common augmentation techniques include random
cropping, flipping, rotation, and zooming.
5. Model training: Train the model on the augmented dataset using techniques such as
stochastic gradient descent (SGD) or Adam optimization. Monitor the training process to
ensure the model is not overfitting or underfitting the data.
12
7. Hyperparameter tuning: Optimize the hyperparameters of the model such as learning
rate, batch size, and number of epochs, to improve the model's performance.
Load Dataset
Accuracy report
Result
13
Fig-5. Workflow of Proposed
Model
14
Create a function to map the age groups to a single group.
15
Encode the label
16
Fourth Stage: Model:
We will use pretrained model to push our accuracy more then we got previously using our
own deep learning neural net.
Alexnet Architecture:
One thing to note here, since Alexnet is a deep architecture, the authors introduced padding to
prevent the size of the feature maps from reducing drastically. The input to this model is the
17
The total number of parameters in this architecture is 62.3 million.
Adam and AdamW are both optimization algorithms commonly used for training deep neural
addresses certain issues with Adam. Here are some key differences between the two
optimizers:
1. Weight decay: Adam and AdamW differ in their implementation of weight decay. Weight
penalty term to the loss function. In Adam, weight decay is implemented by adding a L2
regularization term to the gradient updates. In contrast, AdamW decouples weight decay from
the gradient updates, meaning that weight decay is applied directly to the weight parameters
instead of modifying the gradient updates. This can help prevent the optimization process
2. Bias correction: Adam and AdamW also differ in their bias correction strategy. Bias
correction is used to correct for the bias introduced in the first few iterations of the
optimization process. In Adam, bias correction is performed using the first and second
moment estimates, while in AdamW, it is performed only on the first moment estimates.
18
3. Convergence: Some research studies have shown that AdamW can lead to faster
In summary, AdamW is a modification of Adam that addresses some issues related to weight
decay and bias correction. It is designed to improve the convergence and generalization
performance of deep neural networks. However, the effectiveness of each optimizer can
depend on the specific problem being solved and the architecture of the neural network.
Loss Function:
Cross entropy loss is a commonly used loss function in machine learning, particularly in
classification tasks. It is used to measure the difference between the predicted probability
In classification tasks, the goal is to predict the probability distribution of the different classes
given an input. For example, in a binary classification problem, the goal is to predict the
probability of an input belonging to one of the two classes. The predicted probabilities can be
obtained by passing the input through a softmax activation function, which outputs a
The cross entropy loss is then calculated by comparing the predicted probability distribution
to the actual distribution of the classes. It measures the amount of information gained by the
model when the predicted probabilities are compared to the true probabilities. The cross
19
where y is the actual probability distribution (represented as a one-hot encoded vector) and
y_hat is the predicted probability distribution. The loss is minimized when the predicted
probability distribution matches the actual distribution, i.e., when the model correctly predicts
The cross entropy loss is widely used in machine learning because it provides a smooth and
continuous measure of the difference between the predicted and actual distributions. It is also
20
configuration file depends on the type of model being loaded.
We then read an input image and preprocess it using the `blobFromImage` function.
Finally, we pass the preprocessed image through the loaded model using the `setInput`
method and obtain the output predictions using the `forward` method.
Conclusion
In this work, it is concluded that age and gender research has been the focus of the last
few years. Despite the fact that many of the strategies of the past focused on issues of
age and sexuality, not so long ago, this work certainly focuses on the compelling
images taken in laboratory settings. Such settings do not adequately reflect the general
appearance types of current reality photos on social networking sites and online
21
archives. Web images, anytime, are not just about how complex they are: they are
equally saturated. Easy access to great collections of high qualities video readings of a
learning machine with ongoing preparation information. CNN can be used to provide
effects of age and age order, not by looking at the smallest size of the uneducated
image of age and sexuality, Finally, I hope that more training material will be found
with work age and gender cohesion that will allow effective techniques from other
forms of big data sets to be used this place. The subsequent framework was tried on the
Adience benchmark of unfiltered images and appeared to fundamentally beat late
cutting edge. Two critical conclusions can be produced using our experimental
outcomes. In the first place, CNN can be utilized to give enhanced age and gender
arrangement results, notwithstanding considering the much little size of contemporary
unconstrained image sets named for age and gender classification. Second, the straight
forwardness of our model suggests that more involved frameworks utilizing all the more
preparing information might well be able to do significantly enhancing results beyond
the one reported here.
Future Scope
The field of age and gender detection using machine learning has a wide range of
future possibilities and applications. Some potential future scopes of the age and
gender detection model include:
22
1. Personalized marketing: Age and gender detection models can be used for
personalized advertising, where ads can be targeted to specific age and gender groups.
Future research could focus on developing models that can detect other attributes, such
as facial expression, ethnicity, or emotional state to enable even more personalized
advertising.
2. Healthcare: Age and gender detection models could be used in healthcare to detect
age-related diseases, monitor patient recovery, and develop personalized treatments.
Future research could focus on developing models that can detect other health-related
attributes and biomarkers.
3. Security systems: Age and gender detection models can be used for identity
verification and access control in security systems. Future research could focus on
developing models that can detect other biometric attributes, such as facial recognition
or iris recognition.
4. Social sciences: Age and gender detection models can be used in social sciences to
study demographics and trends in population. Future research could focus on
developing models that can detect other social attributes, such as income, education, or
occupation.
5. Human-robot interaction: Age and gender detection models can be used for human-
robot interaction, where robots can adapt their behavior and communication style to
specific age and gender groups. Future research could focus on developing models that
can detect other human attributes, such as emotions and personality traits.
6. Education: Age and gender detection models can be used in educational settings to
provide personalized learning experiences based on the age and gender of the students.
Future research could focus on developing models that can detect other learning-related
attributes, such as learning styles or cognitive abilities.
Overall, the future scope of age and gender detection models is vast, and there are
many potential applications in various fields. Continued research and development in
this area could lead to exciting new possibilities and advancements.
23
References
2. Hang Qi and Liqing Zhang,” Age Classification System with ICA Based Local
24
Facial Features”, 2009 Springer-Verlag Berlin Heidelberg.
3. Eran Eidinger, Roee Enbar, and Tal Hassner,” Age and Gender Estimation of
Unfiltered Faces”, 2014 IEEE.
9. Y. Fu, G. Guo, and T. S. Huang. “Age synthesis and estimation via faces: A
survey”, Trans. Pattern Anal. Mach. Intell., 32(11):1955–1976, 2010.
25