Professional Documents
Culture Documents
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)
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
This is to certify that the project report entitled“Gender and Age Classification”,being
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
Dr. R. Sridevi,
Professor,
Department of Computer Science and Engineering
This is to certify that the project report “Gender and Age Classification”, being
submitted by Rohith Reddy(19011P0515), Sowmya Raye(19011P0523),Sahithi
Dr D. Vasumathi
Professor & Head of the Department
(Department of Computer Science & Engineering)
Date:
ACKNOWLEDGEMENT
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.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
LITERATURE SURVEY
2. LITERATURE SURVEY
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.
OVERVIEW OF TECHNOLOGIES
3. OVERVIEW OF TECHNOLOGIES
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)
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
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 :
INSTALLATION
5. INSTALLATION
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
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
The convolutional neural network for this python project has 3 convolutional layers:
It has 2 fully connected layers, each with 512 nodes, and a final output layer of softmax type.
● Detect faces
● Classify into Male/Female
● Classify into one of the 8 age ranges
● Put the results on the image and display it
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.
● 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.
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
TEST-1
OUTPUT:
TEST - 2
OUTPUT:
TEST - 3
OUTPUT :
CHAPTER 8
CONCLUSION
8.CONCLUSION
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. \
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
https://paperswithcode.com/sota
https://www.analyticsvidhya.com/blog/2021/05/convolutional-neural-networ
ks-cnn/
https://www.python.org/downloads/