You are on page 1of 43

GENDER AND AGE CLASSIFICATION

A mini project report submitted in partial fulfillment of the requirements for the
award of the
Degree of Bachelor of Technology
In
Computer Science and Engineering (CSE)

By
Rohith Reddy(19011P0515)
Sowmya Raye(19011P0523)
Sahithi V(19011P0528)

Under the guidance of


Dr. R. SRIDEVI
Professor of CSE, JNTUH-CEH
Department of Computer Science and Engineering

Jawaharlal Nehru Technological University

Hyderabad JNTUH College of Engineering,

Science & Technology, Hyderabad - 500085.

DECLARATION BY THE CANDIDATES

We, Rohith Reddy(19011P0515), Sowmya Raye (19011P0523), Sahithi V


(19011P0528) hereby certifies that the project report entitled “Gender and Age Classification”
carried out under the guidance of Dr. R. Sridevi, , is submitted in partial fulfillment of the
requirements for the award of the degree of Bachelor of Technology in Computer Science and
Engineering. This is a record of bona fide work carried out by us and the results embodied in this
project have not been reproduced /copied from any source.

The results embodied in this project report have not been submitted to any other
University or Institute for the award of any other degree or diploma.

Rohith Reddy(19011P0515),
Sowmya Raye(19011P0523),
Sahithi V(19011P0528)
Department of Computer Science and Engineering

Jawaharlal Nehru Technological University

Hyderabad JNTUH College of Engineering,

Science & Technology, Hyderabad - 500085

CERTIFICATE BY THE SUPERVISOR

This is to certify that the project report entitled“Gender and Age Classification”,being

submitted by Rohith Reddy(19011P0515), Sowmya Raye(19011P0523),Sahithi

V(19011P0528), for the award of the degree of Bachelors of Technology in Computer Science &

Engineering, is a record of bonafide work carried out by them and the results produced are

verified and found satisfactory.

Dr. R. Sridevi,
Professor,
Department of Computer Science and Engineering

Jawaharlal Nehru Technological University

Hyderabad JNTUH College of Engineering,

Science & Technology, Hyderabad - 500085

CERTIFICATE BY THE HEAD

This is to certify that the project report “Gender and Age Classification”, being
submitted by Rohith Reddy(19011P0515), Sowmya Raye(19011P0523),Sahithi

V(19011P0528) in partial fulfillment is a record of Bonafide work carried out by

them. The results are verified and found satisfactory.

Dr D. Vasumathi
Professor & Head of the Department
(Department of Computer Science & Engineering)

Date:
ACKNOWLEDGEMENT

I would like to express sincere thanks to our Supervisor Dr. R Sridevi,


Professor of Computer Science and Engineering Department, JNTUH-CEH for her
admirable guidance and inspiration both theoretically and practically and most
importantly for the drive to complete the project successfully. Working under such
an eminent guide was our privilege.

I owe a debt of gratitude to Dr D. Vasumathi madam, Professor & Head of


the Department of Computer Science & Engineering, for her kind consideration
and encouragement in carrying out this project successfully.

I am grateful to the Project Review Committee members and the Department of


Computer Science & Engineering who have helped in successfully completing this
project by giving their valuable suggestions and support.

I express thanks to our parents for their love, care and moral support without
which we would have not been able to complete this project. It has been a constant
source of inspiration for all our academic endeavors. Last but not the least, we
thank the Almighty for making us a part of the world.

Rohith Reddy(19011P0515),
Sowmya Raye(19011P0523),
Sahithi V(19011P0528).
ABSTRACT

This project focuses on the problem of gender and age classification for an
image. We build off of previous work that has developed efficient, accurate architectures
for these tasks and aim to extend their approaches in order to improve results. The first
main area of experimentation in this project is modifying some previously published,
effective architectures used for gender and age classification. Our attempts include
reducing the number of parameters, increasing the depth of the network, and modifying
the project. This verified suspicions I had that the tasks of age and gender classification
are more prone to overfitting than other types of classification.

The next facet of my project focuses on coupling the architectures for age and
gender recognition to take advantage of the gender-specific age characteristics and age-
specific gender characteristics inherent to images. This stemmed from the observation
that gender classification is an inherently easier task than age classification, due to both
the fewer number of potential classes and the more prominent intra gender facial
variations. By training different age classifiers for each gender I found that I could
improve the performance of age classification,although gender classification did not see
any significant gains.
TABLE OF CONTENTS

ABSTRACT 6

CONTENTS 7

1. INTRODUCTION
1.1 Introduction
1.2 Motivation
1.3 Problem statement
1.4 Report organization
2. LITERATURE SURVEY
3. OVERVIEW OF TECHNOLOGIES
3.1 Technologies used
3.2 Packages used
4. SYSTEM SPECIFICATION
4.1 Software Requirements
4.2 Hardware Requirements
5. INSTALLATION
5.1 Python Installation
6. IMPLEMENTATION
6.1 The CNN Architecture
6.2 The Data Set
6.3 Prerequisites
6.4 Flow Chart
6.5 Source Code
7. TESTING AND RESULTS
8. CONCLUSION
8.1 Work Carried out
8.2 Future scope

9. REFERENCES
9.1 Web resources

CHAPTER 1

INTRODUCTION
1.INTRODUCTION
1.1 Introduction
“Gender And Age Classification” helps to approximately find the age in a specific range
and also identifies the gender when given an image or via webcam. It is based on deep learning
using CNN(Convolutional Neural Network)

1.1.1Deep Learning
Deep learning is a subset of machine learning, which is essentially a neural network with
three or more layers. These neural networks attempt to simulate the behavior of the human
brain—albeit far from matching its ability—allowing it to “learn” from large amounts of data.
While a neural network with a single layer can still make approximate predictions, additional
hidden layers can help to optimize and refine for accuracy. Deep learning neural networks, or
artificial neural networks, attempts to mimic the human brain through a combination of data
inputs, weights, and bias. These elements work together to accurately recognize, classify, and
describe objects within the data. Deep learning drives many artificial intelligence (AI)
applications and services that improve automation, performing analytical and physical tasks
without human intervention. Deep learning technology lies behind everyday products and
services (such as digital assistants, voice-enabled TV remotes, and credit card fraud detection) as
well as emerging technologies (such as self-driving cars).

1.1.2 Convolutional Neural Network


A Convolutional Neural Network (ConvNet/CNN) is a Deep Learning algorithm which
can take in an input image, assign importance (learnable weights and biases) to various
aspects/objects in the image and be able to differentiate one from the other. The pre-processing
required in a ConvNet is much lower as compared to other classification algorithms. While in
primitive methods filters are hand-engineered, with enough training, ConvNets have the ability
to learn these filters/characteristics.

The architecture of a ConvNet is analogous to that of the connectivity pattern of Neurons


in the Human Brain and was inspired by the organization of the Visual Cortex. Individual
neurons respond to stimuli only in a restricted region of the visual field known as the Receptive
Field. A collection of such fields overlap to cover the entire visual area.

1.2 Motivation
Human Classification is an age-old procedure and being done in various fields and
technology such as biometrics, forensics sciences, Image processing, Identification system, etc.
With the development of Artificial Intelligence and techniques such as Neural Network and Deep
Learning, it has become increasingly easier to classify humans.
These new technologies help identification, classification of Individuals without the need
of another professional or Individual records. Also Being immensely fast, these technologies can
classify millions of individuals way faster than a professional.
Human Facial Image Processing provides many clues and cues applicable to industries
such as security, entertainment, etc .
This data (a human face image) is very valuable as it helps with recognition, selection or
identification of individuals according to the requirement. Age and Gender Detection can alone
provide a lot of information to places such as recruitment teams of organizations, Verification of
ID cards, example: Voter ID cards which millions of individuals use to cast their vote at the time
of election, etc. Human Facial Image processing eases the task of finding ineligible or counterfeit
individuals

1.3 Problem Statement


Automatically detecting the gender of a person or estimating his/her age is valuable in
many fields of work. The predicted gender may either be “male” and “female”, and the predicted
age may be one of the following ranges of 0-100((2-4), (4-6), (8-12), (15-20), (25-32), (38-43),
(48-53), (60-100)). It is very difficult to accurately guess an exact age from a single image
because of factors like makeup, lighting, obstructions, and facial expressions. Hence, this is a
classification problem instead of regression.

1.4 Report Organization

Chapter 2: Provides an overview of the literature Survey.


Chapter 3: Gives an overview of technologies used.
Chapter 4: Gives an overview about the system specifications.
Chapter 5: Provides a detailed information on installation of the required IDE’s.
Chapter 6: Implementation of the project is understood.
Chapter 7: Deals with the testing and results of the proposed system.
Chapter 8: Gives Conclusions detected from the results followed by the references.
CHAPTER 2

LITERATURE SURVEY
2. LITERATURE SURVEY

Learning Distance Functions using Equivalence Relations:


An algorithm which makes use of side-information in the form of equivalence relations to learn a
Mahalanobis metric. We have shown that our method is optimal under several criteria, and also
showed considerable improvement in clustering on several standard datasets. RCA is one of
several techniques which we have developed for using equivalence relations to enhance
unsupervised learning. In a related technique, we introduced the constraints into an EM
formulation of a Gaussian Mixture Model.

Facial age estimation based on label-sensitive learning and age-oriented


regression:
This paper provides a new age estimation approach, which distinguishes itself with the following
three contributions. First, we combine distance metric learning and dimensionality reduction to
better explore the connections between facial features and age labels. Second, to exploit the
intrinsic ordinal relationship among human ages and overcome the potential data imbalance
problem, a label-sensitive concept and several imbalance treatments are introduced in the system
training phase. Finally, an age-oriented local regression is presented to capture the complicated
facial aging process for age determination. The simulation results show that our approach
achieves the lowest estimation error against existing methods.

Return of the Devil in the Details: Delving Deep into Convolutional Nets:
The latest generation of Convolutional Neural Networks (CNN) have achieved impressive results
in challenging benchmarks on image recognition and object detection, significantly raising the
interest of the community in these methods. Nevertheless, it is still unclear how different CNN
methods compare with each other and with previous state-of-the-art shallow representations such
as the Bag-of-Visual-Words and the Improved Fisher Vector. This paper conducts a rigorous
evaluation of these new techniques, exploring different deep architectures and comparing them
on a common ground, identifying and disclosing important implementation details. We identify
several useful properties of CNN-based representations, including the fact that the
dimensionality of the CNN output layer can be reduced significantly without having an adverse
effect on performance. We also identify aspects of deep and shallow methods that can be
successfully shared. In particular, we show that the data augmentation techniques commonly
applied to CNN-based methods can also be applied to shallow methods, and result in an
analogous performance boost. Source code and models to reproduce the experiments in the paper
is made publicly available.

WLD: a robust local image descriptor:


Inspired by Weber's Law, this paper proposes a simple, yet very powerful androbust local
descriptor, called the Weber Local Descriptor (WLD). It is based on the fact that human
perception of a pattern depends not only on the change of a stimulus (such as sound, lighting) but
also on the original intensity of the stimulus. Specifically, WLD consists of two components:
differential excitation and orientation. The differential excitation component is a function of the
ratio between two terms: One is the relative intensity differences of a current pixel against its
neighbors, the other is the intensity of the current pixel. The orientation component is the
gradient orientation of the current pixel. For a given image, we use the two components to
construct a concatenated WLD histogram. Experimental results on the Brodatz and
KTH-TIPS2-a texture databases show that WLD impressively outperforms the other widely used
descriptors (e.g., Gabor and SIFT). In addition, experimental results on human face detection
also show a promising performance comparable to the best known results on the MIT+CMU
frontal face test set, the AR face data set, and the CMU profile test set.
Age estimation using a hierarchical classifier based on global and local
facial features:
The research related to age estimation using face images has become increasingly important, due
to the fact it has a variety of potentially useful applications. An age estimation system is
generally composed of aging feature extraction and feature classification; both of which are
important in order to improve the performance. For the aging feature extraction, the hybrid
features, which are a combination of global and local features, have received a great deal of
attention, because this method can compensate for defects found in individual global and local
features. As for feature classification, the hierarchical classifier, which is composed of an age
group classification (e.g. the class of less than 20 years old, the class of 2039 years old, etc.) and
a detailed age estimation (e.g. 17, 23 years old, etc.), provide a much better performance than
other methods. However, both the hybrid features and hierarchical classifier methods have only
been studied independently and no research combining them has yet been conducted in the
previous works.
CHAPTER 3

OVERVIEW OF TECHNOLOGIES
3. OVERVIEW OF TECHNOLOGIES

3.1 Technologies used


Python : Python is a programming language, which means it’s a language both people and
computers can understand. Python was developed by a Dutch software engineer named Guido
van Rossum, who created the language to solve some problems he saw in computer languages of
the time. Python is an interpreted high-level programming language for general-purpose
programming. Created by Guido van Rossum and first released in 1991, Python has a design
philosophy that emphasizes code readability, and a syntax that allows programmers to express
concepts in fewer lines of code, notably using significant whitespace. It provides constructs that
enable clear programming on both small and large scales. Python features a dynamic type system
and automatic memory management. It supports multiple programming paradigms, including
object-oriented, imperative, functional and procedural, and has a large and comprehensive
standard library. Python interpreters are available for many operating systems. C Python, the
reference implementation of Python, is open source software and has a community-based
development model, as do nearly all of its variant implementations. C Python is managed by the
non-profit Python Software Foundation.

Python can be used for Pretty Much Anything : One significant advantage of learning Python
is that it’s a general-purpose language that can be applied in a large variety of projects. Below are
just some of the most common fields where Python has found its use: Data science Scientific
and mathematical computing
Web development
Computer graphics
Basic game development
Mapping and geography (GIS software)

3.2. Libraries used from python for this project :

1. Math : Math module provides various value of various constants like pi, tau. Having such
constants saves the time of writing the value of each constant every time we want to use it and
that too with great precision. Constants provided by the math module are-
Euler’s Number, Pi, Tau, etc

2. Argparse: It is a standard library (included with Python) and very simple to use because of
the work that happens behind the scenes. For example, this library can differentiate between both
the arguments and options that are defined using add_arguments () method automatically.
The argparse module makes it easy to write user-friendly command line interfaces.

The program defines what arguments it requires, and argparse will figure out how to parse those
out of sys.argv. The argparse module also automatically generates help and usage messages and
issues errors when users give the program invalid arguments.

3. OpenCV: OpenCV (Open Source Computer Vision Library) is an open source computer
vision and machine learning software library. OpenCV was built to provide a common
infrastructure for computer vision applications and to accelerate the use of machine perception in
the commercial products. Being an Apache 2 licensed product, OpenCV makes it easy for
businesses to utilize and modify the code.
CHAPTER 4

SYSTEM SPECIFICATIONS
3. SYSTEM SPECIFICATIONS

3.1. HARDWARE SPECIFICATIONS :

1. Processor : Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz, 2592 Mhz, 6 Core(s), 12 Logical
Processor(s)
2. Hard Disk : Above 100 GB 4. RAM : 8 GB 3.2.

3.2.SOFTWARE SPECIFICATIONS :

1. Operating System : Windows 10 or later


2. User Interface : ATOM
3. Language : Python
CHAPTER 5

INSTALLATION
5. INSTALLATION

5.1 Python Installation


Installing and using Python on Windows 10 is very simple. The installation procedure involves
just three steps:

1. Download the binaries


2. Run the Executable installer
3. Add Python to PATH environment variables

To install Python, you need to download the official Python executable installer. Next, you need
to run this installer and complete the installation steps. Finally, you can configure the PATH
variable to use python from the command line. You can choose the version of Python you wish
to install. It is recommended to install the latest version of Python, which is 3.7.3 at the time of
writing this article.

Step 1: Download the Python Installer binaries Open the official Python website in your
web browser. Navigate to the Downloads tab for windows.
Choose the latest Python 3 release. In our example, we choose the latest Python 3.7.3 version.
Click on the link to download Windows x86 executable installer if you are using a 32-bit
installer. In case your Windows installation is a 64-bit system, then download Windows x86-64
executable installer
Step 2: Run the Executable Installer

1. Once the installer is downloaded, run the Python installer.


2. Check the Install launcher for all users check box. Further, you may check the
Add Python 3.7 to path check box to include the interpreter in the execution path.

Select Customize installation. Choose the optional features by checking the


following check boxes:
3. Documentation pip
4. tcl/tk and IDLE (to install tkinter and IDLE)
5. Python test suite (to install the standard library test suite of Python)
6. Install the global launcher for `.py` files. This makes it easier to start Python
7. Install for all users.

Click Next. 8. This


takes you to Advanced Options available while installing Python. Here, select the
Install for all users and Add Python to environment variables check boxes.
Optionally, you can select the Associate files with Python, Create shortcuts for
installed applications and other advanced options. Make note of the python
installation directory displayed in this step. You would need it for the next step.
After selecting the Advanced options, click Install to start installation.
10. Once the installation is over, you will see a Python Setup Successful window.

Step 3: Add Python to environmental variables

The last (optional) step in the installation process is to add Python Path to the System
Environment variables. This step is done to access Python through the command line. In case
you have added Python to environment variables while setting the Advanced options during the
installation procedure, you can avoid this step. Else, this step is done manually as follows. In the
Start menu, search for “advanced system settings”. Select “View advanced system settings”. In
the “System Properties” window, click on the “Advanced” tab and then click on the
“Environment Variables” button. Locate the Python installation directory on your system. If you
followed the steps exactly as above, python will be installed in below locations:
Step 4: Verify the Python Installation

You have now successfully installed Python 3.7.3 on Windows 10. You can verify if the Python
installation is successful either through the command line or through the IDLE app that gets
installed along with the installation. Search for the command prompt and type “python”. You can
see that Python 3.7.3 is successfully installed.
CHAPTER 6

IMPLEMENTATION
6. IMPLEMENTATION

6.1 The CNN Architecture

The convolutional neural network for this python project has 3 convolutional layers:

● Convolutional layer; 96 nodes, kernel size 7


● Convolutional layer; 256 nodes, kernel size 5
● Convolutional layer; 384 nodes, kernel size 3

It has 2 fully connected layers, each with 512 nodes, and a final output layer of softmax type.

To go about the python project, we’ll:

● Detect faces
● Classify into Male/Female
● Classify into one of the 8 age ranges
● Put the results on the image and display it

6.2 The Dataset

For this python project, we’ll use the Adience dataset; the dataset is available in the public
domain. This dataset serves as a benchmark for face photos and is inclusive of various real-world
imaging conditions like noise, lighting, pose, and appearance. The images have been collected
from Flickr albums and distributed under the Creative Commons (CC) license. It has a total of
26,580 photos of 2,284 subjects in eight age ranges (as mentioned above) and is about 1GB in
size. The models we will use have been trained on this dataset.

6.3 Prerequisites

1. You’ll need to install OpenCV (cv2) to be able to run this project. You can do this with
pip-
Other packages you’ll be needing are math and argparse, but those come as part of the standard
Python library.

2. We use the argparse library to create an argument parser so we can get the image argument
from the command prompt. We make it parse the argument holding the path to the image to
classify gender and age for.

The models and files required:

● opencv_face_detector.pbtxt
● opencv_face_detector_uint8.pb
● age_deploy.prototxt
● age_net.caffemodel
● gender_deploy.prototxt
● gender_net.caffemodel
● a few pictures to try the project on

3. For face, age, and gender, initialize protocol buffer and model.

4. Initialize the mean values for the model and the lists of age ranges and genders to classify
from.

5. Now, use the readNet() method to load the networks. The first parameter holds trained weights
and the second carries network configuration.
6. Let’s capture video stream in case you’d like to classify on a webcam’s stream. Set padding to
20.

7. Now until any key is pressed, we read the stream and store the content into the names
hasFrame and frame. If it isn’t a video, it must wait, and so we call up waitKey() from cv2, then
break.

8. Let’s make a call to the highlightFace() function with the faceNet and frame parameters, and
what this returns, we will store in the names resultImg and faceBoxes. And if we got 0
faceBoxes, it means there was no face to detect.

Here, net is faceNet- this model is the DNN Face Detector and holds only about 2.7MB on disk.

● Create a shallow copy of frame and get its height and width.
● Create a blob from the shallow copy.
● Set the input and make a forward pass to the network.
● faceBoxes is an empty list now. for each value in 0 to 127, define the confidence
(between 0 and 1). Wherever we find the confidence greater than the confidence
threshold, which is 0.7, we get the x1, y1, x2, and y2 coordinates and append a list
of those to faceBoxes.
● Then, we put up rectangles on the image for each such list of coordinates and return
two things: the shallow copy and the list of faceBoxes.

9. But if there are indeed faceBoxes, for each of those, we define the face, create a 4-dimensional
blob from the image. In doing this, we scale it, resize it, and pass in the mean values.

10. We feed the input and give the network a forward pass to get the confidence of the two class.
Whichever is higher, that is the gender of the person in the picture.

11. Then, we do the same thing for age.

12. We’ll add the gender and age texts to the resulting image and display it with imshow().
6.4 Flow Chart
6.5 Source code:
CHAPTER 7

TESTING AND RESULTS


7. TESTING AND RESULTS

TEST-1

OUTPUT:
TEST - 2

OUTPUT:
TEST - 3

OUTPUT :
CHAPTER 8

CONCLUSION
8.CONCLUSION

8.1 WORK CARRIED OUT

We implemented an age and gender classification project using python and deep
learning techniques where it can detect the age and gender of human beings present in an image.

“Human Age and gender classification” are two of the many important information
gathering resource from and individual. Human faces provide enough data which may be used
for many purposes. In order to reach the correct audience human age and gender classification is
very essential. Here we tried to do the same process but with general equipment. The efficiency
of the algorithm depends on several factor but the main motif of this project is being easy and
faster while also being as accurate as possible.Work is being done to the improve the efficiency
of the algorithm. \

8.2 FUTURE SCOPE

Some future improvements include discarding the face like non-human objects, more datasets
for people belonging to different ethnic groups and more granular control over the workflow of the
algorithm.
CHAPTER 9

REFERENCES
9. REFERENCES

9.1 Web Resources

[1] Information about gender and age classification :

https://paperswithcode.com/sota

[2] Information about Deep Learning and Convolutional Neural Network :

https://www.analyticsvidhya.com/blog/2021/05/convolutional-neural-networ
ks-cnn/

[3] Python Installation :

https://www.python.org/downloads/

You might also like