Final Review Gender Classification
Final Review Gender Classification
GENDER
CLASSIFICATION OF
IMAGES identifying faces…
1
Click to edit Master title style
Group members
Guide
Dr Durga prasad
2 2
Click to edit Master title style
INDEX
. Introduction . Literature review
3 3
GENDER
Click to editCLASSIFICATION
Master title style
The aim of gender classification is to recognize the gender of a person
based on the characteristics that differentiate between masculinity
and femininity.
4
EXISTING WORK
Click to edit Master title style
GPU:
As our input data increases computation of the calculations
become complex, so we’ll be using GPU for parallel
computation which results in less processing time.
8 8
Click to edit Master title style
Convolutional neural
network : ConvNet/ cnn is a Deep Learning algorithm which can
take in an input image, assign learnable weights and
biases to various aspects/objects in the image and be able
to differentiate one from the other nn—Sequential.
Our model will be able to classify images on the basis of the gender.
Whether the given image is of a male or female with the use of lconvolutional
neural networks. In other words We will be collecting data and will associate
a gender (male or female) with it , according to the result of our analysis.
1010
Click to edit Master title style
Real time usage
The development and progress in gender recognition technology has lead
to many potential uses in a large application scope, because the gender
classification techniques can significantly improve the computer’s
perceptional and interactional capabilities.
1111
Click to edit Master title style
1.Human-Computer Interaction
In the field of HCI , Robots or computers need to
identify and verify human gender to improve the
system performance based on personalized information.
2. surveillance systems
classifying gender in surveillance systems for public places
(e.g., bank, school) can assist intelligent security and
surveillance systems to track moving objects, detect abnormal
behaviors, and facilitate the security investigation off criminals
who intentionally try to hide their identity information.
1212
Click to edit
3.Commercial Master title style
Development
Gender classification is useful for guiding effective
marketing and establishing smart shopping environment, in
which production can be directed to specific users through
websites, electronic marketing, and advertising, etc.
4. Demographic Research
The application of a gender classification system helps
demographic research in efficiently collecting demographic
information.
1313
Click to edit Master title style
5. Mobile Application and Video Games
Gender classification can provide supportive information to improve the
user experience in mobile applications (apps) and video games. In mobile
apps, some researchers use this method to facilitate the use of the mobile
Internet by customizing apps according to gender.
In video games, male and female often have different preferences, which
would enable the use of gender information to provide their preferred
game characters or contents.
1414
Click to edit Master title style
“
HARDWARE
REQUIREMENTS
•Modern Operating System:
15
Click to edit Master title style
“ SOFTWARE REQUIREMENTS
PYTHON WITH LIBRARIES :
•
•
•
•
Pytorch
Matplotlib
Numpy
Torchvision
• Resnets, Convolutional Neural network (cnn)
1616
System architecture
Click to edit Master title style
17
Click tostart
1. We editwith Master
the input pass title style
it through the first convolutional layer take its
output then pass it to batch normalization layer and relu actication function.
2. Then we take the output from the above layers and pass it through
convolutional layer batch normalization relu and max pooling then we pass
the output to our two of the residual layers which consist of convolutional
batch normalization and relu .
3. Now the output of this residual layer is added with the input which we passed
in those residual layers after max pooling.
4. Now we will repeat the whole procedure again this will be our residual layer
number two.
5 And the output which we will get from this second residual layer is sent to max
pooling then we flatten out the feature maps and pass them through linear layer
which will give us 2 outputs one for male and one for female .
1818
LITERATURE
Click to edit Master title style
REVIEW
A gender classification system uses face of a person from a given image to
tell the gender (male/female) of the given person. A successful
gender classification approach can boost the performance of many
applications including face recognition, smart human-computer
interface and computer-aided physiological or psychological analysis.
Usually facial images are used to extract features and then a
classifier is applied to the extracted features to learn a gender
recognizer. It contains a wide range of information regarding the
characteristics difference between male and female.
19
Click to edit Master title style
The gender classification result is often a binary value, e.g., 1 or 0, representing either male or
female. The purpose of gender classification is to determine the gender of a person based on the
characteristics that appear in a person. The most commonly used methods for gender
classification are SVM(with RBF Kernel) and Adaboost combined with Linear SVM.In this project
we are using Convolutional Neural Network and ResNet to recognize the gender.
Convolutional neural network (CNN) is a class of artificial neural networks that has become
dominant in various computer applications. CNN is designed to automatically and adaptively learn
spatial hierarchies of features through back propagation by using multiple building blocks, such as
convolution layers, pooling layers, and fully connected layers. It is an active learning approach
which takes input as multimedia like images, videos or various 2D/3D data. It consists of
different weights for every hidden neuron expressed in mathematical expression of multi-
dimensional matrix. CNN frameworks are designed by a well-fixed combination of layers such as
narrow layers, sub sample layers, and full layers.
2020
Click to edit Master title style
ResNEt stands for Residual Networks. In this network we use a technique called skip connections .
The skip connection skips training from a few layers and connects directly to the output. The
advantage of adding this type of skip connection is because if any layer hurt the performance of
architecture then it will be skipped by regularization. So, this results in training very deep neural
network without the problems caused by vanishing/exploding gradient.
A significant advantage of the CNN over conventional approaches in pattern recognition is its ability to
simultaneously extract features, reduce data dimensionality, and classify in one network structure.
The CNN also has the ability to extract topological properties from a raw input image with no or
minimal preprocessing required. Our model consists of 8 convolutional layers and 2 residual layers in
cnn model.
2121
MODULE
Click to edit Master title style
DESCRIPTION
WE are making a gender classification
model with the help of cnn which
contains a corpus of 28k images.
22
Click to edit Master title style
MODULE WORK FLOW
EXPLANATION
• downloading the dataset
We will start by downloading the dataset
in our jupyter notebook. Now this can be
easily done using “opendatasets” library
in python. We will import the library and
will use its “download” to download the
dataset by passing the link of the dataset
as a parameter in the download function
24
WClick
e w i lto
l aedit
p p l y Master
r a n d o m ltitle
y chostyle
sen transformations while loading
images from the training dataset. Specifically, we will pad each
image by 4 pixels, and then take a random crop of size 32 x 32
pixels, and then flip the image horizontally with a 50%
probability. Since the transformation will be applied randomly
and dynamically each time a particular image is loaded, the
model sees slightly different images in each epoch of training,
which allows it generalize better.
2525
Setting up the
Click to edit gpu
Master title style
GPU, graphics processing unit is a
hardware.As the sizes of our models
and datasets increase, we need to use
GPUs to train our models within a
reasonable amount of time. GPUs
contain hundreds of cores optimized
for performing expensive matrix
operations on floating-point numbers
quickly, making them ideal for training
deep neural networks.
> The training_step function generates the predictions and calculates the loss using the cross
entropy function.
>the validation_step function generates the predictions calculates the loss using cross entropy
and calculates the accuracy using the acuuracy function which we defined using the torch.tensor
functions it calculates the accuracy of the model's prediction on an batch of inputs.
>validation_epoch_end function combines the accuracy and loss of all the batches by taking their
average and gives us an overall validation loss and accuracy
>epoch_end function prints all the results the training loss, validation loss and validation
accuracy .
2727
applying convolutional
Click to edit Master title style
neural networks and maxpool
We will use a convolutional neural network, using
the nn.Conv2d class from PyTorch.
The 2D convolution is a fairly simple operation we start with
a kernel, which is simply a small matrix of weights. This
kernel “slides” over the 2D input data, performing an
element wise multiplication with the part of the input it is
currently on, and then summing up the results into a single
output pixel
2828
There are certain advantages offered by
convolutional layers when working with image data:
Click to edit Master title style
>Fewer parameters: A small set of parameters (the kernel) is used to
calculate outputs of the entire image, so the model has much fewer parameters .
compared to a fully connected layer.
>Sparsity of connections: In each layer, each output element only depends on a
small number of input elements,
>Parameter sharing and spatial invariance: The features learned by a kernel in
one part of the image can be used to detect similar pattern in a different part of
another image.
29
Click to edit Master title style
3131
Click to edit Master title style Adding some
improvements
Before we train the model, we're going to make a bunch of
small but important improvements to our fit function:
32
Click to edit Master title style
IMPLEMENTAT
ION
AND
CODE
SNAPS 35
Click to edit Master title style
Downloading the data set
3636
Click to edit Master
Importing title style
Libraries :
3737
Click to edit Master title style
Exploring the Data :
3838
Click to edit Master title style
Exploring the Data :
3939
Applying DataMaster
Click to edit Augmentation
title styleand
Normalization:
4040
Click to editBatches
Creating Master title
: style
4141
Click to editBatches
Creating Master title
: style
4242
Click to edit
Setting upMaster title style
the GPU :
4343
Click to edit Master title style
Setting up the GPU :
4444
Click to edit Master title style
Defining the Model :
4545
Click to editthe
Defining Master title style
Model :
4646
Applying Convolutional
Click to edit Neural
Master title style
Networks :
4747
Click to edit Master title style
4848
Click to edit
Adding theMaster title style
Improvements :
4949
Click to edit Master title style
5050
Click to editthe
Training Master title style
Model :
5151
Click to edit Master title style
5252
Click to edit Master title style
5353
Click to edit Master title style
5454
Click to edit Master title style
5555
Click to edit Master title style
5656
Testing
Click and
to edit result:-
Master title style
Image 1:
As we can see our label and predicted value is same i.e. female. Hence, our model works successfully. 5757
Testing
Click to editand result:-
Master title style
Image 2:-
As we can see our label and predicted value is same i.e. male. Hence, our model works successfully. 5858
Click to edit Master title style
Conclusion:-
•w e c a n s e e t h a t o u r m o d e l o f g e n d e r c l a s s i f i c a t i o n w o r k s
s u c c e s s f u l l y w i t h 9 8 % a c c u r a c y. W e b u i l d o u r m o d e l b y
going through various steps which involves : downloading
the required dataset, displaying the image, normalization
and augmentation of the data. Then we worked on setting
up the GPU. Thereafter we defined the model based on the
key points extracted by then. Then by applying
convolutional neural networks and maxpool, we further
directed our project. Residual blocks were added to
improve the performance of our model. Some additional
improvements were made to our fit function. Then we
finally trained our model and tested it. With all these key-
algorithms, we obtained a successful Gender 5959
Classification Model.
Click to edit Master title style
Thank You
60