Report

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Identifying Gender From Images of Faces

Abstract

The objective of this project is to identify the gender of a person by looking at his/her photograph. This is a case of
supervised learning where the algorithm is first trained on a set of female and male faces, and then used to classify new data.
Wehave not taken genders other than M ale and Female into account. A preliminary algorithm is run to make sure that an
imageis that of a human beforeclassification begins.

I. Intr oduct ion matical equations governing these methods will not be
discussed in this report.
Previous research has shown that our brain has special-
ized nerve cells responding to specific local features
of a scene, such as lines, edges, angles or movement.
Our visual cortex combines these scattered pieces of
information into useful patterns. Automatic face recog- II. Dat a Set and Pr ocessin g
nition aims to extract these meaningful pieces of infor-
mation and put them together into a useful representa-
tion in order to perform a classifi cation/ identifi cation The data we have is a set of high resolution colour im-
task on them. ages of 396 female faces and 389 male faces obtained
While we attempt to identify gender from facial from the MUCT database. All images are frontal views
features, we are often curious about what features of of the face. The database provides diversity of lighting,
the face are most important in determining gender. age and ethnicity.
Are localized features such as eyes, nose and ears more The images also have variations in :
important or overall features such as head shape, hair
line and face contour more important? subject’s head rotation and tilt
There are a plethora of successful and robut face subject’s facial expression
recognition algorithms on the web. Instead of using subject’s face/ Hair accessories
the inbuilt tools that they provide, we start building position of the face in the image
various algorithms from scratch to gain a rich learning However, this challenging database was chosen to
experience. make room for imrpovements in the algorithm.
In this project, the following methods were used
for classifi cation : This data has been used in four different ways
Eigenface Method on a single algorithm so that we can study how sen-
K-means sitive it is to the data quality. We run a python
script to center all the images in our database - by
GDA that performs supervised learning on re-
duced space of PCA centering the images the faces are aligned at the
axis of symmetry of the face. Hehce, we have a
SVM that performs supervised learning on re-
set of centered and uncentered images. We also
duces space of PCA
use coloured (RGB) and B/ W versions of the given
Fisherfaces Method
images. Colour images have been compressed to
SVM that performs supervised learning on fea-
140x140 pixels and B/ W to 64x48 pixels. We now
tures provided by the Histogram of Oriented
have four different datasets: Dataset1(centered, RGB),
Gradients (HOG) method
Dataset2(centered,B/ W), Dataset3(uncentered,RGB)
We look at how these methods perform on our
and Dataset4(uncentered, B/ W).
data, discuss the relative advantages and disadvan-
tages of these methods and investigate the limitations The dataset has been split into training set and test
on accuracy posed by the dataset itself. The mathe- set as summarized in the following table:

1
Table 1: Dataset of faces female subjects who have short hair, hair tied back or
in a scarf were almost always labeled male. Having
Gender Training Set Test Set insufficient examples for them to train on might have
resulted in this outcome. Another key observation is
Male 200 169
that, the male faces are better centered and hence male
Female 200 189
faces have a more reliable eigenspace.

In this project, we define misclassifi cation error as:


No. of images miscclassi f ied
Error = (1)
No. of images

III. Eigenf ace Met hod


A popular method in face recognition is the Eigenface
algorithm. It takes a holistic approach by processing
the entire face and coming up with an eigenface basis. Figure 1: Plot of nearest distanceof femalefaces in test set from
In this method, a Principle Component Analysis (PCA) female(red) and male(blue) Eigenfaces
is performed to reduce the dimensionality of
The performance of this algorithm is discussed
here:

Table 2: EigenfaceMethod on Dataset 4

Gender Training Error Test Error


Male 0.8 0.03
Female 0.14 0.28
Figure 2: Plot of nearest distance of male faces in test set from
female(red) and male(blue) Eigenfaces
Table 3: EigenfaceMethod on Dataset 3
Running the same algorithm on Dataset 3 reduced
the excessive bias towards males, as now the female
Gender Training Error Test Error faces were equally well-centered.
Male 0.6 0.14 In all cases, the number of principal components
Female 0.11 0.16 was chosen to be 200. We obtained this result by elimi-
nating all eigen values whose value is zero. A k-fold
cross validation was performed to decide the number
On Dataset 4, the algorithm shows very good recog-
of dimensions in the reduced space more precisely.
nition for males but a very poor one for females. We
This resulted in a reduced dimension of 170.
conclude here that the algorithm is basically identi-
Below is a figure showing some images in the train-
fying almost every new face to be male, hence con-
ing set and the corresponding Eigenfaces:
tributing to the large error for females. The figure
below demonstrates this. When a male face is pro-
jected onto the male eigenspace, the resultant reduced-
dimension vector matches the other male faces very
well. But when a female face is projected onto the
female eigenspace, the resultant reduced-dimension
vector does not match the female faces very well. In-
fact, it favours females over males only about 28 % of
the time.
One disadvantage of PCA is that it cannot give
you an intuitive sense of why the algorithm is favour-
ing males. But upon looking at the data where the
algorithm misclassifi es the person, we conclude that Figure 3: A sampleof training set data

2
Table 6: PCA and GDA method on Dataset 2

Gender Test Error


Male 0.11
Female 0.11

Table 7: PCA and GDA on Dataset 1

Gender Test Error


Figure 4: Eigenfaces of theabovesample
Male 0.55
Female 0.7

IV. K-mean s
A k-fold cross validation was done to determine the
We apply K-means directly on the pixel data that we number of PCAs required, and we found the optimal
get from images to obtain 10 clusters for female faces value to be 100. In order to visualize how GDA works
and 10 for male faces. We would like to call these the with this data, we take 3 Principal Components and
10 most representative female and male faces. We then obtain the following plot:
run the K Nearest Neighbours algorithm to classify our
test images. K was chosen to be 5 after analysing the
performance of the algorithm (using cross validation)
for all possible values of K.
This is done on Dataset 3 and Dataset 4. We get the
following results:

Table 4: K-means on Dataset 4

Gender Test Error


Male 0.22
Female 0.16

Figure 5: Implementing GDA for K = 3

Table 5: K-means on Dataset 3


VI. PCA wit h SVM
Gender Test Error
SVM is yet another way of performing supervised
Male 0.12
learning over the reduced space. A k-fold cross-
Female 0.13
validation was performed to chose the number of PCAs
and 150 was found to be optimum. Cross validation
was done for k = (10,20,30..200). This interval was
arrived at after random sampling of k’s.
V. PCA wit h GDA The PCA was applied to reduce dimensionality of
the vectors that serve as inputs to the SVM . The SVM
The Eigenface method classifi es new data based on then does supervised learning. Sometimes this method
what the nearest vector is in terms of euclidean dis- is called the fisher discriminant analysis. Visualizing
tance. Instead of using the nearest neighbour approach, this data in the large dimensional space is hard, so we
we can perform supervised learning over the reduced do it in 2D. We clearly need more attributes to classify
space. GDA is one such attempt. the data.

3
Table 11: FishfaceMethod on Dataset 3

Gender Test Error


Male 0.25
Female 0.40

VIII. Hist ogr am of Or ient ed Gr adient s


Figure 6: Implementing SVM for K = 2
and SVM
Performance of this algorithm is :
As a foray into applying advanced and effective gender
classifi cation algorithms, we have used supervise SVM
Table 8: PCA and SVM on Dataset 4
learning after extracting HOG descriptors of human
faces. For this particular algorithm, we used code that
Gender Test Error was available online.
Male 0.10 We carry out the scheme in B/ W space and use
Female 0.13 L-2 normalization for block normalization. For this
method, images were not normalized during pre-
processing. Also, the images were not centered because
this method is invariant to geometric transformations
Table 9: PCA and SVM on Dataset 3
of images.
A plot of gradients show what the most descriptive
Gender Test Error
cues are that the SVM learns over. This is the only algo-
Male 0.90 rithm that can give us an insight as to which physical
Female 0.10 part of the face contributes most to gender detection.
The accuracy that this algorithm provides is the
best of all. The algorithm also does not seem to be
VII. Fischer Faces limited by the challenges that the data poses, giving us
equally good results for both centered and uncentered
When PCA reduces the dimension in which we work, data.
it definitely obtains the most representative reduced
space. But it does nothing to make sure that these at- Table 12: FisherfaceMethod on Dataset 3
tributes also represent the salient differences between
the male class and female class. Our algorithm’s main Gender Test Error
aim should be to identify these features and give them Male 0.17
highest priority while classifying them. Female 0.20
Fisherfaces instead tries to maximize the variance
between classes, instead of variance within a class.
Hence it is much better suited for the gender classifi ca- Table 13: FishfaceMethod on Dataset 4
tion task.
As expected, Fisher Faces gives us remarkable re- Gender Test Error
sults of 10 % on uncentered data and 3 % on centered
data. ALso 10 % is what all the algorithms converge Male 0.20
to when used on uncentered data. This throws light Female 0.23
on the importance of centering it, as information about
features can be very crucial in classifying it correctly. The gradient images of our dataset tells us that
these are the fundamental differences between male
Table 10: FisherfaceMethod on Dataset 4 and female faces:
The interior of a female face has softer face con-
Gender Test Error tours
Male 0.90
Female features are spread over larger areas than
Female 0.11
male features

4
The outline of a male face face is more rugged and provides an input to a supervised learn-
compared to a female face ing algorithm. These algorithms are more
Turns out that these differences are key in classi- robust to geometric variations in dataset.
fying a person to be male or female.
X. Fut ur e Wor k

Now that we have quantitative yardsticks


for masculinity and feminity of a person,
we could extend this knowledge to quantify
what is perceived as beauty. Conventionally,
beatiful people are known for epitomizing
either masculinity or feminity. We use this
hypothesis in devising our algorithm.
For this we need a dataset of images where
each image is ranked on the basis of its at-

Figure 7: HOG descriptors of human faces

IX. Discussi on

Gender classifi cation algorithms can be of two


types:

– Pictorial: The algorithm reads pixel data


into an array and uses statistical tools to
process that array and make classifi cation.
Such algorithms require a dataset where all
images are properly aligned, without any
noise.
– Geometric: The algorithm reads pixel data
and gets information on features such as
width of jaw, curvature of cheek etc. It using
this new information as the attribute space

You might also like