0% found this document useful (0 votes)
78 views16 pages

A Mini Project Report On Age and Gender Detection-2

The document outlines a mini project conducted by students at Savitribai Phule Pune University focused on implementing a deep learning model for gender and age detection from facial images. The project utilizes the UTK Face dataset and employs deep neural networks to classify gender and predict age, emphasizing the significance of facial analysis in various applications. The report includes methodology, results, and acknowledgments, highlighting the contributions of faculty and peers in the project's completion.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
78 views16 pages

A Mini Project Report On Age and Gender Detection-2

The document outlines a mini project conducted by students at Savitribai Phule Pune University focused on implementing a deep learning model for gender and age detection from facial images. The project utilizes the UTK Face dataset and employs deep neural networks to classify gender and predict age, emphasizing the significance of facial analysis in various applications. The report includes methodology, results, and acknowledgments, highlighting the contributions of faculty and peers in the project's completion.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

SAVITRIBAI PHULE PUNE UNIVERSITY

Deep Learning
Mini project on

Implement Gender and Age Detection: predict if person is a


male or female and also their age
Submitted to the

Savitribai Phule Pune University


In partial fulfilment for the award of the

Degree of Bachelor of Engineering


(COMPUTER ENGINEERING)

Submitted By

1. Shivani Dole Exam Seat No:-B190754229


2. Shubhangi Shinde Exam Seat No-B1907504308
3. Pratiksha Thorat Exam Seat No:-B1907504319
4. Bhagyashree Ghadage Exam Seat No.-B190754238

Under the guidance of


Dr. A. B. Gavali
DEPARTMENT OF COMPUTER ENGINEERING

S.B. PATIL COLLEGE OF ENGINEERING INDAPUR-413106


2024-25
CERTIFICATE
This is to certify that

1. Shivani Dole Exam Seat No.-B190754229


2. Shubhangi Shinde Exam Seat No.-B1907504308
3. Pratiksha Thorat Exam Seat No.-B1907504319
4. Bhagyashree Ghadage Exam Seat No.-B190754238

Class Fourth Year Branch Computer Engineering has successfully completed the work
asunciated with Deep Learning(410251) titled as
Implement Gender and Age Detection: predict if a person is a male or female and
also their age and has submitted the work book associated under my supervision, in
the partial fulfilment of Fourth Year Bachelor of Engineering (Choice Based Credit
System) (2019 course) of Savitribai Phule Pune University.

Date:
Place: Indapur

Guide Head Of Department Principal


(Dr.A.B.Gavli) (Dr. S. T. Shirkande) (Dr. S. T. Shirkande )
ACKNOWLEDGMENT

We take great pleasure in submitting the project report on the topic:


"Implement Gender and Age Detection: Predict if a Person is Male or Female
and Estimate Their Age."
First and foremost, we would like to thank the Almighty for giving us the strength and
perseverance to complete the report we started.
We would like to express our sincere gratitude to our guide, Dr. A. B. Gavli, for their
invaluable instruction, continuous support, and for sharing ideas and real-life examples
throughout the course. Without their guidance and motivation, this report would not
have been completed.
We are also extremely thankful to Dr. S. T. Shirkande, Head of the Computer
Engineering Department at S.B. Patil College of Engineering, Indapur, for his
continuous support and valuable suggestions.
We are especially grateful to our Principal, Dr. S. T. Shirkande, for his
encouragement, insightful guidance, and for dedicating his valuable time to discuss
and review our work.
We extend our heartfelt thanks to all the faculty members, parents, and colleagues who
directly or indirectly contributed to the successful completion of this project. We are
also thankful for the useful feedback and suggestions provided by the reviewers, which
significantly improved the quality of our project.
The three members of our group were a constant source of encouragement throughout
this journey, and we approached the project with dedication and appreciable effort.
Lastly, we wish to express our sincere gratitude.

1. Shivani Dole
2. Shubhangi Shinde
3. Pratiksha Thorat
4. Bhagyashree Ghadage
Index

Sr. No. Title Page No

1 Abstract 3

2 Introduction 4

3 Methodology 5

4 Source Code and Output 6

5 Conclusion 10
ABSTRACT

With the growing importance of facial analysis in modern technology,


predicting age and gender from face images has emerged as a crucial area
of research. It has a wide range of applications across various domains,
including security systems, targeted marketing, surveillance, human-
computer interaction, and even social and matrimonial platforms. Accurate
age and gender prediction helps enhance user experiences, improve service
personalization, and strengthen identity verification systems.
This project explores the use of deep learning techniques, particularly Deep
Neural Networks (DNNs), to estimate a person’s age and gender from a
single image or frame captured through a camera or video. By analyzing
facial features, our system attempts to classify gender and predict the age
group of the individual in a fast and efficient manner.
The report highlights how advanced deep learning algorithms can be
leveraged for this purpose, showcasing their effectiveness in real-time
applications. It also discusses the process of building, training, and
evaluating a deep learning model capable of making reliable predictions
based on facial input data.
The main objective of this mini project is to design and implement a model
that utilizes deep learning to accurately estimate the age and gender of a
person based on facial image input, demonstrating its practical relevance
and potential in real-world use cases.

Keywords: Deep Learning, Deep Neural Network, Gender Classification,


Age Detection, Facial Recognition, Image Analysis
INTRODUCTION

Age and gender play a vital role in human interaction, social


communication, and decision-making processes. The ability to
automatically determine these attributes from facial images has become
increasingly important with the growing use of smart technologies,
biometric systems, and social media platforms. As digital interactions
continue to evolve, the demand for reliable and accurate age and gender
prediction systems has significantly increased.
Facial images are among the most accessible and informative data sources
for such analysis, as they contain a rich set of features that can be used to
identify key demographic traits. In recent years, deep learning techniques
have revolutionized the field of computer vision, offering more accurate
and robust solutions compared to traditional machine learning approaches.
The typical pipeline for age and gender prediction involves several key
stages, including face detection, image preprocessing, feature extraction,
and final classification or regression. While early systems depended heavily
on handcrafted features and traditional classifiers, the emergence of
Convolutional Neural Networks (CNNs) and Deep Neural Networks
(DNNs) has allowed for automatic feature learning directly from the raw
input data, improving prediction performance across diverse datasets.
Facial analysis not only helps in estimating age and gender but also reveals
emotional states, behavioral patterns, and other valuable indicators. These
insights are useful in a wide range of domains such as security surveillance,
digital marketing, human-computer interaction, healthcare diagnostics,
recruitment processes, and user-targeted content delivery.
This project presents a deep learning-based approach to predict a person’s
gender (male or female) and estimate their age range using facial imagery.
By leveraging powerful neural network architectures and a well-curated
dataset, the system aims to deliver efficient and reasonably accurate
predictions that can be applied to real-world scenarios.
METHODOLOGY

DEEP LEARNING
Deep learning is an artificial intelligence (AI) technique that seeks to learn
from experience and resemble the human brain. Through a training
procedure, these representations are learned. To teach the software how to
detect an object, we must first train it with a large number of object images
that we categorize according to different classes. Deep learning-based
algorithms, on average, require a large amount of training data and take
longer to train than traditional machine learning methods.
Finding unique attributes when trying to recognize any object or character
in an image is time-consuming and complex. Unlike traditional machine
learning, where features are manually retrieved, problems can be solved
using deep learning approaches which extract important characteristics
from data automatically. A neural network with multiple hidden layers is
known as deep learning. They may build complicated notions from simple
concepts after an image has been passed through the network.
By integrating simple elements such as shape, edges, and corners, an image
can be trained in the network to learn items such as characters, faces, and
so on. As the image travels through the layers, each one gets a simple
property while moving on to the next. As the layers grow deeper, the
network may learn more complex features and eventually merge them to
identify the image. In the field of computer vision, deep learning has
discovered a wide range of uses. The domains that work with facial data are
among the most important computer vision applications.

DEEP NEURAL NETWORK (DNN)


Many modern deep learning models are based on artificial neural
networks—specifically Convolutional Neural Networks (CNNs)—
although they can also include propositional formulas, latent variables, and
stacked layer-wise deep generative models such as the nodes in Deep Belief
Networks and Deep Boltzmann Machines. In deep learning, each level
learns to transform its input data into a slightly more abstract and composite
representation. In an image recognition application, the raw input may be a
matrix of pixels; the first representational layer may abstract the pixels and
encode edges; the second layer may combine and render arrangements of
edges; the third layer may encode a nose and eyes; and the fourth layer may
recognize that the image contains a face.
Importantly, a deep learning process can learn features automatically, which
means it learns to optimally place each level on its own. This does not
eliminate the need for hand-tuning—for example, varying the number of
layers and layer sizes can provide different degrees of abstraction.

FACE DETECTION
Face detection, also called facial detection, is an artificial intelligence (AI)-
based computer technology used to find and identify human faces in digital
images and video. Face detection technology is often used for surveillance
and tracking of people in real-time. It is used in various fields including
security, biometrics, law enforcement, entertainment, and social media.
Face detection uses Machine Learning (ML) and Artificial Neural Networks
(ANN) for training and plays an important role in face tracking, face
analysis, and facial recognition. In face analysis, face detection uses facial
expressions to identify which parts of an image or video should be focused
on to determine age, gender, and emotions. In a facial recognition system,
face detection gathers data required to generate a faceprint and match it with
other stored faceprints.

Upload Image

Face Detection

Age and Gender


Detection

Result

Fig. 2. working Diagram


AGE AND GENDER DETECTION
Age and gender detection refer to the process of determining the age and
gender of people in an image or video. This process allows essential data to
be obtained and used effectively in various business development
processes.
Artificial intelligence-based facial analysis technologies have gained
significant importance. The key factor underlying the popularity of these
technologies is their ability to be applied effectively in business
environments. The most widely used artificial intelligence technologies for
facial analysis are age detection and gender detection systems.
CONCLUSION
Age and gender classification are two of the most essential methods for
obtaining information about an individual. Human faces contain enough
data to be useful for a wide variety of applications. Classifying human age
and gender is crucial for targeting the right audience.
In this project, we attempted to replicate this process using standard
equipment. The algorithm's efficiency is influenced by several factors, but
the primary goal of this study is to make it as simple and fast as possible
while maintaining a high level of accuracy. Ongoing work aims to further
enhance the algorithm's performance.
Future improvements may include filtering out non-human objects,
incorporating more diverse datasets with people from different ethnic
backgrounds, and enabling the system to have more precise control over its
processing flow. Deep learning and DNNs could help boost the prototype’s
ability to accurately identify a person’s gender and age range from a single
facial image.
From this study, we can draw two important conclusions. First, even with
limited availability of age- and gender-labeled images, DNNs can
significantly enhance age and gender prediction results. Second, the
system's performance can be further improved by introducing more
extensive training data and implementing more sophisticated models.
Deep Learning Mini Project

Title: Implement Gender and Age Detection: Predict if a Person is Male or


Female and Also Estimate Their Age

Project Title: "Gender and Age Detection on UTK Face Dataset"

Objective: To build a deep neural network model that can recognize gender and age
from the UTK Face dataset.

Theory:
• Collect and Prepare the Dataset:
To begin building a gender and age prediction model using deep learning, the
first step is to gather a dataset containing labelled facial images. In this project,
we utilize the UTK Face dataset, which includes over 20,000 images of human
faces of various ages, genders, and ethnicities. Each image filename encodes the
age and gender, making it easy to extract labels. Before feeding the data to the
model, we must perform preprocessing. This includes resizing the images to a
uniform dimension (e.g., 200x200 pixels), normalizing pixel values to improve
model convergence, and possibly limiting the maximum age to 100 years to
reduce the impact of outliers. Additionally, shuffling the dataset ensures that the
model doesn't learn any hidden order or bias present in the raw data.
• Split the Dataset:
After preparing the data, the next step is to split the dataset into training,
validation, and testing sets. A typical distribution is 80% for training, 10% for
validation, and 10% for testing. The training set is used to learn the model
parameters, the validation set helps fine-tune hyperparameters and prevent
overfitting, and the test set evaluates the final performance on unseen data. A
well-maintained split ensures that the model generalizes effectively and doesn't
just memorize the training examples.
• Define Data Generators:
Since loading the entire dataset into memory may be inefficient, especially with
large datasets, we use data generators to load the data in batches during training.
Keras provides an efficient tool called ImageDataGenerator, which can also
perform real-time data augmentation. This means that during training, the model
sees slightly altered versions of the images—through operations like rotation,
zoom, brightness adjustment, and horizontal flipping—which helps improve the
model’s robustness. For age and gender prediction, we need to ensure the
generator can yield multiple outputs (age and gender), which may involve
custom data generators or multi-output pipelines.
• Define the Neural Network Model:
The core of the system is a Convolutional Neural Network (CNN), which is
well-suited for image-related tasks. The CNN architecture typically begins with
several convolutional layers that detect spatial hierarchies in the data, followed
by pooling layers that reduce dimensionality. After a few layers of feature
extraction, the output is flattened and passed into dense (fully connected) layers.
The final layers branch out into two separate outputs: one for gender
classification (with a sigmoid activation for binary output: male/female) and
another for age regression (with a linear or ReLU activation to predict
continuous age values). The model is compiled using a multi-output loss
function, combining binary cross-entropy for gender and mean squared error
(MSE) for age. An optimizer such as Adam or RMSprop is used to adjust the
model’s weights efficiently during training.
• Train and Evaluate the Model:
After defining the model architecture, the training process begins by feeding in
the training and validation datasets through the generators. The model learns the
patterns in the facial features that correspond to different ages and genders.
During training, metrics such as accuracy (for gender) and mean absolute error
(for age) are monitored. Once the training is complete, the model’s performance
is assessed using the test dataset. This step is crucial to ensure the model
performs well on unseen data and isn’t overfitted.
• Save and Deploy the Model:
Once the model shows satisfactory performance, it is saved in a suitable format
(e.g., .h5 for Keras) for later use. The trained model can be deployed in real-
world applications such as face recognition systems, demographic analysis
tools, or embedded in mobile/desktop applications. A GUI or web interface can
also be built to allow users to upload images and get predictions in real-time.

Conclusion
This project successfully implements age and gender prediction using CNNs on the
UTK Face dataset, showcasing effective use of deep learning for facial analysis.
Source Code

script.py
import cv2
import argparse
def highlightFace(net, frame, conf_threshold=0.7):
frameOpencvDnn = frame.copy()
frameHeight = frameOpencvDnn.shape[0]
frameWidth = frameOpencvDnn.shape[1]
blob = cv2.dnn.blobFromImage(frameOpencvDnn, 1.0, (300, 300), [104, 117, 123],
swapRB=True, crop=False)
net.setInput(blob)
detections = net.forward()
faceBoxes = []
for i in range(detections.shape[2]):
confidence = detections[0, 0, i, 2]
if confidence > conf_threshold:
x1 = int(detections[0, 0, i, 3] * frameWidth)
y1 = int(detections[0, 0, i, 4] * frameHeight)
x2 = int(detections[0, 0, i, 5] * frameWidth)
y2 = int(detections[0, 0, i, 6] * frameHeight)
faceBoxes.append([x1, y1, x2, y2])
cv2.rectangle(frameOpencvDnn, (x1, y1), (x2, y2),
(0, 255, 0), int(round(frameHeight / 150)), 8)
return frameOpencvDnn, faceBoxes
parser = argparse.ArgumentParser()
parser.add_argument('--image', help='Path to image file', required=True)
args = parser.parse_args()
image = cv2.imread(args.image)
if image is None:
print("Could not read image. Please check the path.")
exit()
faceProto = "opencv_face_detector.pbtxt"
faceModel = "opencv_face_detector_uint8.pb"
ageProto = "age_deploy.prototxt"
ageModel = "age_net.caffemodel"
genderProto = "gender_deploy.prototxt"
genderModel = "gender_net.caffemodel"
MODEL_MEAN_VALUES = (78.4263377603, 87.7689143744, 114.895847746)
ageList = ['(0-2)', '(4-6)', '(8-12)', '(15-20)',
'(25-32)', '(38-43)', '(48-53)', '(60-100)']
genderList = ['Male', 'Female']
faceNet = cv2.dnn.readNet(faceModel, faceProto)
ageNet = cv2.dnn.readNet(ageModel, ageProto)
genderNet = cv2.dnn.readNet(genderModel, genderProto)
resultImg, faceBoxes = highlightFace(faceNet, image)
if not faceBoxes:
print("No face detected")
exit()
for faceBox in faceBoxes:
padding = 20
face = image[max(0, faceBox[1]-padding):min(faceBox[3]+padding,
image.shape[0]-1),
max(0, faceBox[0]-padding):min(faceBox[2]+padding, image.shape[1]-1)]
blob = cv2.dnn.blobFromImage(face, 1.0, (227, 227), MODEL_MEAN_VALUES,
swapRB=False)
genderNet.setInput(blob)
genderPreds = genderNet.forward()
gender = genderList[genderPreds[0].argmax()]
print(f'Gender: {gender}')
ageNet.setInput(blob)
agePreds = ageNet.forward()
age = ageList[agePreds[0].argmax()]
print(f'Age: {age}')
cv2.putText(resultImg, f'{gender}, {age}', (faceBox[0], faceBox[1]-10),
cv2.FONT_HERSHEY_SIMPLEX, 0.8, (0, 255, 255), 2, cv2.LINE_AA)
cv2.imshow("Detecting age and gender", resultImg)
cv2.waitKey(0)
cv2.destroyAllWindows()

Output
.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy