Report Writing
Report Writing
at
AUG-DEC,2023
SUBMITTED BY:
Gedela RamaKrishna Vara Prasad
(2004910)
i
Student’s Declaration
I hereby certify that the work which is being presented in this training report with the project
PRASAD University Roll No. 2004910 in partial fulfillment of requirements for the award of
INSTITUTE). The matter presented has not been submitted by me in any other University /
(Signature of Student)
This is to certify that the above statement made by the candidate is correct to the best of my
knowledge.
Signature of HOD
ii
ABSTRACT
The field of machine learning is introduced at a conceptual level. Ideas such as supervised and
unsupervised as well as regression and classification are explained. The trade-off between bias,
variance, and model complexity is discussed as a central guiding idea of learning. Various types
of model that machine learning can produce are introduced such as the neural network (feed-
forward and recurrent), support vector machine, random forest, self-organizing map, and
Bayesian network. Training a model is discussed next with its main ideas of splitting a dataset
into training, testing, and validation sets as well as performing cross-validation. Assessing the
goodness of the model is treated next alongside the essential role of the domain expert in keeping
the project real. The chapter concludes with some practical advice on how to perform a machine
learning project. Since the advent of social media, there has been an increased interest in
automatic age and gender classification through facial images. So, the process of age and gender
classification is a crucial stage for many applications such as face verification, aging analysis, ad
targeting and targeting of interest groups. Yet most age and gender classification systems still
have some problems in real-world applications. This work involves an approach to age and
gender classification using multiple convolutional neural networks (CNN). The proposed method
has 5 phases as follows: face detection, remove background, face alignment, multiple CNN and
voting systems. The multiple CNN model consists of three different CNN in structure and depth;
the goal of this difference It is to extract various features for each network. Each network is
trained separately on the AGFW dataset, and then we use the Voting system to combine
iii
ACKNOWLEDGEMENT
I am highly grateful to the Dr. Sehijpal Singh , Principal, Guru Nanak Dev Engineering
College (GNDEC), Ludhiana, for providing this opportunity to carry out Six Months industrial
The constant guidance and encouragement received from Dr. K. S. Mann, Head of the
Department, GNDEC Ludhiana has been of great help during the training and project work and
I would like to express a deep sense of gratitude and thanks profusely to MANISH Director of
Company. Without the wise counsel and able guidance, it would have been impossible to
is greatly acknowledged.
Finally, I am indebted to all whosoever have contributed in this report work and friendly stay at
iv
LIST OF FIGURES
2.4 Pycharm 14
2.5 ArgParse Dataset 16
2.6 NumPy Library 18
5.1 Output 1 38
5.2 Output 2 39
5.3 Output 3 40
5.4 Output 4 41
5.5 Output 5 41
5.6 Camera-Output 1 42
5.7 Terminal-Output for Camera-Output 1 42
5.8 Camera-Output 2 43
5.9 Terminal-Output for Camera-Output 2 43
v
CONTENTS
1.3. Description 2
1.4. Layout of the basic idea 5
CHAPTER 2 TECHNOLOGY AND DATASET USED 10-21
2.1. Deep learning 10
2.2. The dataset 13
2.3. Essential libraries and tools used 14
CHAPTER 3 HARDWARE AND SOFTWARE REQ. 22
CHAPTER 4 TECHNOLOGY AND IMPLEMENTATION 23-37
4.1. Import the libraries and load the dataset 23
4.2. Pre-process the data 25
4.3. Create the model 28
4.4. Train the model 31
4.5. Evaluate the model 33
4.6. Running real-time embedded system 36
4.7. Summary 37
CHAPTER 5 RESULTS 38-43
5.1. Screenshots 38
5.2. Compiler output 42
CHAPTER 6 CONCLUSION AND FUTURE SCOPE 44-45
6.1. Conclusion 44
6.2. Future scope 45
REFERENCES 46
APPENDIX 47-50
CHAPTER 1 INTRODUCTION
To build a gender and age detector that can approximately guess the gender and age of
the person (face) in a picture using Deep Learning on the Adience dataset.
In this Python Project, we Generally use Deep Learning to accurately identify the
gender and age of a person from a single image of a face. I used the models trained
by Tal Hassner and Gil Levi. The predicted gender may be one of ‘Male’ and
‘Female’, and the predicted age may be one of the following ranges- (0 – 2), (4 – 6),
(8 – 12), (15 – 20), (25 –32), (38 – 43), (48 – 53), (60 – 100) (8 nodes in the final
softmax layer). It is very difficult to accurately guess an exact age from a single
image because of factors like makeup, lighting, obstructions, and facial expressions.
And so, we make this a classification problem instead of making it one of regression.
1.2 Objectives
• Ensure the system works well in different conditions like varied lighting and facial
expressions.
• Develop accurate algorithms to predict age and gender from facial images.
It has 2 fully connected layers, each with 512 nodes, and a final output layer of softmax
type.
-Detect faces
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
1.3 Description
To make machines more intelligent, the developers are diving into machine learning
and deep learning techniques. A human learns to perform a task by practicing and
repeating it again and again so that it memorizes how to perform the tasks. Then the
2
neurons in his brain automatically trigger and they can quickly perform the task they
have learned. Deep learning is also very similar to this. It uses different types of neural
recognition, image and sound classification, object detection, image segmentation, etc.
In this python project, we implemented a CNN to detect gender and age from a single
picture of a face.
Prerequisites:
-You’ll need to install OpenCV (cv2) to be able to run this project. You can do this
-Other packages you’ll be needing are math and argparse, but those come as part of
What is OpenCV?
OpenCV is short for Open Source Computer Vision. Intuitively by the name, it is an
open-source Computer Vision and Machine Learning library. This library is capable
of processing real-time image and video while also boasting analytical capabilities. It
supports the Deep Learning frameworks TensorFlow, Caffe, and PyTorch. It plays a
major role in real-time operation which is very important in today’s systems. By using
it, one can process images and videos to identify objects, faces, or even handwriting
of human. When it integrated with various libraries, Such as Numpy, python is capable
of Processing the OpenCV array structure for analysis. To Identify image pattern and
3
its various features we use vector space and perform mathematical operations on these
features.
The first OpenCV version was 1.0. OpenCV is released under a BSD License and
hence it’s free both academic and commercial use. It has C++, C, Python and Java
interfaces and supports Windows, Linux, Mac OS, IOS and Android. When openCV
was designed the main focus was real-time applications for computational efficiency.
All things are written in optimized C/C++ to take advantage of multi-core processing.
effective in handling image classification tasks. It can capture the Temporal and Spatial
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.
enough training, ConvNets have the ability to learn these filters/characteristics. The
kernel is just like a small window sliding over the large window in order to extract the
spatial features and in the end, we get feature maps. A Convolutional Neural Network
(CNN) is a type of neural network architecture designed for tasks involving images
and spatial data. CNNs are particularly effective in computer vision tasks, such as
CNNs is inspired by the visual processing that occurs in the human brain.
4
Fig 1.1 Movement of the Kernel
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 overlaps to cover the entire
visual area.
-opencv_face_detector.pbtxt
-opencv_face_detector_uint8.pb
-age_deploy.prototxt
-age_net.caffemodel
-gender_deploy.prototxt
-gender_net.caffemodel
5
-a few pictures to try the project on
1. For face detection, we have a .pb file- this is a protobuf file (protocol buffer); it holds
the graph definition and the trained weights of the model. We can use this to run the
trained model.
2. For face, age, and gender, ini.pbtxt extension holds it in text format.These are
TensorFlow files. For age and gender, the .prototxt files describe the network
configuration and the .caffemodel file defines the internal states of the parameters of
the layers. TensorFlow uses Protocol Buffers (protobuf) to serialize structured data, and
it commonly uses files with the extension .pb or .pbtxt. However, the specific contents
and purpose of these files depend on their context. They could be saved models,
configuration files, or other types of data. If you are referring to "servables" or model
configuration files for TensorFlow Serving, you might have encountered .pbtxt files
used to define configurations. These files contain information about the model, such as
the input and output nodes, data types, and other settings.
A .prototxt file is a text file used in the context of deep learning, particularly with the
Caffe deep learning framework. It is a configuration file that defines the architecture of
format used in the Caffe deep learning framework. It contains the learned parameters
(weights and biases) of a trained neural network model. When you train a neural
network using Caffe, the model's architecture and its learned parameters are saved
separately. The architecture is stored in a .prototxt file, while the learned parameters
6
Fig 1.2 TensorFlow Working
3. 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
7
Fig 1.3 Age Prediction
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
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
8
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.
• 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().
9
CHAPTER 2 TECHNOLOGY AND DATASET USED
Deep learning is an artificial intelligence (AI) function that imitates the workings of
the human brain in processing data and creating patterns for use in decision making.
Deep learning has evolved hand-in-hand with the digital era, which has brought about
an explosion of data in all forms and from every region of the world. This data, known
simply as big data, is drawn from sources like social media, internet search engines,
1. Deep Learning is a subfield of Machine Learning that involves the use of neural
networks to model and solve complex problems. Neural networks are modeled
after the structure and function of the human brain and consist of layers of
Deep Learning is the use of deep neural networks, Which have multiple layers
data by discovering hierachical patterns and features in the data. Deep Learning
algorithms can automatically learn and improve from data without the need for
10
recommendation systems. Some of the popular Deep Learning architectures
recognition accuracy at higher levels than ever before. This helps consumer
improved to the point where deep learning outperforms humans in some tasks
like classifying objects in images. While deep learning was first theorized in the
1980s, there are two main reasons it has only recently become useful: 1. Deep
learning requires large amounts of labeled data. For example, driverless car
have a parallel architecture that is efficient for deep learning. When combined
training time for a deep learning network from weeks to hours or less. A
designed for tasks involving images and spatial data. CNNs are particularly
visual processing that occurs in the human brain. Recurrent Neural Networks
previous inputs. This memory makes them well-suited for tasks involving
11
sequences, such as time series prediction, natural language processing, and
speech recognition.
12
Fig 2.3 DBNs
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
13
2.3 Essential Libraries and tools used:
1. Pycharm
tester, integration with version control systems (VCSes), and supports web
Community Edition is released under the Apache License, and there is also
PyCharm is widely used in the Python community and is known for its rich feature
set, ease of use, and continuous improvement through regular updates. It is available
14
2. Math Library: Introduction
The Python Math Library provides us access to some common math functions and
constants in Python, which we can use throughout our code for more complex
don't have to do any installation to use it. In this article, we will be showing example
usage of the Python Math Library's most used functions and constants. This module
functions cannot be used with complex numbers; use the functions of the same name
from the cmath module if you require support for complex numbers. The distinction
between functions which support complex numbers and those which don’t is made
since most users do not want to learn quite as much mathematics as required to
that the programmer can determine how and why it was generated in the first place.
3. Argparse:
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.
15
Fig 2.5 ArgParse Dataset
parameter has its own more detailed description below, but in short they are:
usage - The string describing the program usage (default: generated from arguments
added to parser)
16
formatter_class - A class for customizing the help output
prefix_chars - The set of characters that prefix optional arguments (default: ‘-‘)
unnecessary)
add_help - Add a -h/--help option to the parser (default: True) allow_abbrev - Allows
exit_on_error - Determines whether or not ArgumentParser exits with error info when
While using computer vision and deep learning to identify the gender of a person may
seem like an interesting classification problem, it’s actually one wrought with moral
implications.
Just because someone visually looks, dresses, or appears a certain way does not imply
17
Software that attempts to distill gender into binary classification only further chains
us to antiquated notions of what gender is. Therefore, I would encourage you to not
If you must perform gender recognition, make sure you are holding yourself
accountable, and ensure you are not building applications that attempt to conform
gender).
There is little value in gender recognition, and it truly just causes more problems than
4. NumPy:
Numeric, the ancestor of NumPy, was developed by Jim Hugunin. Another package
Numarray was also developed, having some additional functionalities. In 2005, Travis
18
Oliphant created NumPy package by incorporating the features of Numarray into
Numeric package. There are many contributors to this open source project.
• NumPy has in-built functions for linear algebra and random number
generation.
NumPy is often used along with packages like SciPy (Scientific Python) and
5. Matplot:
Matplot library is a python library used to create 2D graphs and plots by using python
scripts. It has a module named pyplot which makes things easy for plotting by
providing feature to control line styles, font properties, formatting axes etc. It supports
a very wide variety of graphs and plots namely - histogram, bar charts, power spectra,
error charts etc. It is used along with NumPy to provide an environment that is an
19
effective open source alternative for MatLab. It can also be used with graphics toolkits
closer to MATLAB
work like MATLAB. Each pyplot function makes in a figure, plots some lines in a
20
6. Pandas:
Pandas is an opensource Python package that is most widely used for data science/data
analysis and machine learning tasks. It is built on top of another package named
Numpy, which provides support for multi-dimensional arrays. As one of the most
popular data wrangling packages, Pandas works well with many other data science
modules inside the Python ecosystem, and is typically included in every Python
distribution, from those that come with your operating system to commercial vendor
Pandas deal with the following three data structures: − Series Data Frame Panel
21
CHAPTER 3 HARDWARE AND SOFTWARE REQ.
1. Hardware Requirements
• RAM 8 GB RAM
2. Software Requirements
Libraries
22
CHAPTER 4 TECHNOLOGY AND IMPLEMENTATION
First, we are going to import all the modules that we are going to need for training our
model. The Keras library already contains some datasets and MNIST is one of them.
So we can easily import the dataset and start working with it. The mnist.load_data()
method returns us the training data, its labels and also the testing data and its labels.
For a face and age detection project, you'll commonly use libraries such as OpenCV
for image processing, and a deep learning library like TensorFlow or PyTorch for
model development. Below is a basic example using Python to import these libraries
and load a dataset. In this example, I'll use TensorFlow and OpenCV.
23
Fig 4.2 Loading Dataset
24
4.2 Pre-process the data
The image data cannot be fed directly into the model so we need to perform some
operations and process the data to make it ready for our neural network. The dimension
of the training data is (60000,28,28). The CNN model will require one more dimension
Data preprocessing is a crucial step in preparing your dataset for training a face and
age detection model. Below are common steps involved in preprocessing data for such
a project:
1. Data Collection:
• Collect a diverse dataset of facial images with associated age and gender
bias.
2. Image Loading:
• Load the facial images into the system. Use a suitable image processing
3. Data Cleaning:
• Check for and handle any missing or corrupted images in the dataset.
4. Face Detection:
each image.
25
5. Face Alignment (Optional):
6. Image Resizing:
7. Normalization:
8. Data Augmentation:
in lighting conditions.
9. Age Labeling:
• Convert age labels into a suitable format for your model. This might involve
26
11. Data Splitting:
• Split the dataset into training, validation, and test sets. This allows you to train
the model on one subset, tune hyperparameters on another, and evaluate the
• If your dataset has imbalanced age or gender classes, consider techniques such
distribution.
• Serialize the preprocessed data into a format suitable for training (e.g., HDF5,
TFRecord). This step is especially important when dealing with large datasets.
• Record any metadata, such as file paths, age labels, and gender labels,
associated with each image. This information is useful for troubleshooting and
analysis.
15. Documentation:
is crucial for reproducibility and sharing insights with other team members.
27
4.3 Create the model
In the part we’ll learn about age detection, including the steps required to automatically
predict the age of a person from an image or a video stream (and why age detection is
best treated as a
From there, we’ll discuss our deep learning-based age detection model and then learn
Controlling a model in a face and age detection project involves managing its behavior,
making adjustments, and ensuring it meets the desired criteria. Here are several aspects
Depending on the application, you may want to accept predictions only if the
2. Dynamic Thresholding:
demographics.
28
3. Feedback Loop:
the model.
time. Log predictions, errors, and model metrics to identify potential issues
early.
• Schedule regular updates to the model using new data. This helps the model
8. Bias Mitigation:
gender and age. Regularly assess and address biases to ensure fair and ethical
outcomes.
29
9. User Interface (UI) Controls:
• Ensure that the model complies with privacy regulations. Implement controls
external inputs.
12. Versioning:
• Maintain version control for the model and its associated components. This
allows for easy rollback in case of issues and facilitates collaboration among
team members.
13. Documentation:
knowledge transfer.
30
14. Adherence to Regulations:
• Ensure that the model and its controls adhere to relevant regulations and
Once your face detector has produced the bounding box coordinates of the face in the
image/video stream, you can move on to Stage #2— identifying the age of the person.
Training a model for face and age detection involves several steps. Here's a high-level
1. Data Collection:
• Gather a diverse dataset of facial images labeled with both age and gender
2. Data Preprocessing:
• Clean and preprocess the dataset. This may involve resizing images,
• Split the dataset into training, validation, and test sets. The training set is used
to train the model, the validation set helps tune hyperparameters, and the test
4. Model Architecture:
• Choose a suitable deep learning architecture for face and age detection.
processing tasks. Ensure the architecture can handle both face and age
5. Loss Function:
• Define a loss function that measures the difference between the predicted and
actual age and gender values. Common loss functions for regression tasks
include mean squared error, and for classification tasks, categorical cross-
entropy.
6. Optimizer:
• Select an optimizer (e.g., Adam, SGD) to minimize the loss during training.
7. Model Training:
• Train the model using the training set. Adjust the model's weights and biases
32
8. Hyperparameter Tuning:
etc.) to optimize the model's performance. Use the validation set to guide this
process.
9. Evaluation:
• Assess the model's performance on the test set. Evaluate metrics such as
accuracy, precision, recall, and F1 score for both age and gender detection.
11. Deployment:
Age detection is the process of automatically discerning the age of a person solely
• Stage #2: Extract the face Region of Interest (ROI), and apply the age detector
33
Evaluating a face and age detection model involves assessing its performance based
on various metrics. Here are steps and key metrics you can use to evaluate the model:
between predicted and actual age values. Lower MAE indicates better
performance.
• Root Mean Squared Error (RMSE): Similar to MAE but gives higher
• Precision, Recall, and F1 Score: Provide insights into the model's ability to
3. Confusion Matrix:
• For both age and gender detection, analyze the confusion matrix to
34
4. Receiver Operating Characteristic (ROC) Curve (Optional):
ROC curves to analyze the trade-off between true positive rate and false
positive rate.
5. Visual Inspection:
This can provide insights into specific challenges the model faces, such as
• Assess the model for bias, especially concerning gender and age groups. Use
7. Cross-Validation:
across different subsets of the data. This helps assess its robustness.
• Evaluate the inference speed and efficiency, especially if real-time applications are
9. Ethical Considerations:
• Assess the model for ethical implications, especially when dealing with
sensitive information such as age and gender. Ensure that the model's
35
10. User Feedback (if applicable):
11. Documentation:
• Document the evaluation process, including the metrics used, their values,
For Stage #1, any face detector capable of producing bounding boxes for faces in an image
can be used, including but not limited to Haar cascades, HOG + Linear SVM, Single Shot
Detectors (SSDs), etc. Exactly which face detector you use depends on your project:
• Haar cascades will be very fast and capable of running in real-time on embedded
devices — the problem is that they are less accurate and highly prone to false-
positive detections.
• HOG + Linear SVM models are more accurate than Haar cascades but are slower.
They also aren’t as tolerant with occlusion (i.e., not all of the face visible) or
• Deep learning-based face detectors are the most robust and will give you the best
accuracy, but require even more computational resources than both Haar cascades
and HOG + Linear SVMs When choosing a face detector for your application, take
36
I also recommend running a few experiments with each of the face detectors so you can
4.7 Summary
There are several factors that determine how old a person visually appears, including
their lifestyle, work/job, smoking habits, and most importantly, genetics. Secondly,
keep in mind that people purposely try to hide their age — if a human struggles to
accurately predict someone’s age, then surely a machine learning model will struggle
as well.
Therefore, you must assess all age prediction results in terms of perceived age rather
than actual age. Keep this in mind when implementing age detection into your own
37
CHAPTER 5 RESULT
5.1 Screenshots
38
Fig 5.2 Output2
39
Fig 5.3 Output3
40
Fig 5.4 Output4
41
5.2 COMPILER OUTPUT:
6.1 CONCLUSION:
We have successfully build Face, c with Python, Tensorflow, and Machine Learning libraries.
Face, Age and Gender Detection have been recognized with more than 97% test accuracy.
This can be also further extended to identifying the Face, Age and Gender correctly . Though
many previous methods have addressed the problems of age and gender classifification, until
recently, much of this work has focused on constrained images taken in lab settings. Such
settings do not adequately reflflect appearance variations common to the real-world images in
social websites and online repositories. Internet images, however, are not simply more
challenging: they are also abundant. The easy availability of huge image collections provides
modern machine learning based systems with effectively endless training data, though this
data is not always suitably labeled for supervised learning. Taking example from the related
problem of face recognition we explore how well deep CNN perform on these tasks using
Internet data. We provide results with a lean deep-learning architecture designed to avoid
overfifitting due to the limitation of limited labeled data. Our network is “shallow” compared
to some of the recent network architectures, thereby reducing the number of its parameters
and the chance for overfifitting. We further inflflate the size of the training data by artifificially
adding cropped versions of the images in our training set. The resulting system was tested on
the Adience benchmark of unfifiltered images and shown to signifificantly outperform recent
state of the art. Two important conclusions can be made from our results. First, CNN can be
used to provide improved age and gender classifification results, even considering the much
smaller size of contemporary unconstrained image sets labeled for age and gender.
44
6.2 FUTURE SCOPE:
The Face Recognition (FR) is growing as a major research area because of the broad choice
based on Visible Spectrum (VS) are facing challenges like object illumination, pose variation,
expression changes, and facial disguises. Unfortunately these limitations decrease the
performance in object identification and verification. To overcome all these limitations, the
Infrared Spectrum (IRS) may be used in human FR. So it leads and encourages the researchers
for continuous research in this area of FR. Simultaneously, the present study emphasizes the
use of three dimensional cubic dataset i.e. Multi/ Hyperspectral Imagery Data in FR. The IR
based Multi/ Hyperspectral Imaging System can minimize the several limitations arise in the
existing and classical FR system because the skin spectra derived with cubic dataset depicts
the unique features for an individual. Multi/ Hyperspectral Imaging System provides valuable
discriminants for individual appearance that cannot be obtained by additional imaging system
that's why this may be the future of human FR. This paper also presents a detailed and time to
45
Refrences
• Aurélien Géron (2019). Hands-on Machine Learning with Scikit- Learn, Keras, and
• Hisham, A., Harin, S. (2017). Deep Learning – the new kid in Artificial Intelligence
• Robin Nixon (2014). Learning PHP, MySQL, JavaScript, CSS & HTML5: A Step-
• Choi, S.E.; Lee, Y.J.; Lee, S.J.; Park, K.R.; Kim, J. Age Estimation Using a
Recognition
• https://www.geeksforgeeks.org/introduction-deep-learning/
• https://www.geeksforgeeks.org/courses/data-science-live
46
APENDIX
import math
import argparse
frameOpencvDnn=frame.copy()
frameHeight=frameOpencvDnn.shape[0]
frameWidth=frameOpencvDnn.shape[1]
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])
47
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')
args=parser.parse_args()
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"
genderList=['Male','Female']
faceNet=cv2.dnn.readNet(faceModel,faceProto)
ageNet=cv2.dnn.readNet(ageModel,ageProto)
48
genderNet=cv2.dnn.readNet(genderModel,genderProto)
padding=20
while cv2.waitKey(1)<0:
hasFrame,frame=video.read()
if not hasFrame:
cv2.waitKey()
break
resultImg,faceBoxes=highlightFace(faceNet,frame)
if not faceBoxes:
face=frame[max(0,faceBox[1]-padding):
min(faceBox[3]+padding,frame.shape[0]-1),max(0,faceBox[0]-padding)
:min(faceBox[2]+padding, frame.shape[1]-1)]
swapRB=False)
genderNet.setInput(blob)
genderPreds=genderNet.forward()
gender=genderList[genderPreds[0].argmax()]
print(f'Gender: {gender}')
49
ageNet.setInput(blob)
agePreds=ageNet.forward()
age=ageList[agePreds[0].argmax()]
50