0% found this document useful (0 votes)
75 views

"Emotion Regognition System": A Project Report ON

This document is a project report submitted by four students - Abhijeet Sarcar, Anshul Anand, Ajeet Kumar, and Pradeep Kumar - for their Bachelor of Technology degree. It presents research on developing an emotion recognition system. The system utilizes techniques like Viola-Jones detection, Harris corner detection, PCA, LDA, HOG features, and SVMs to extract faces and facial features from images and classify seven fundamental human emotions. The hybrid approach combines initial classification using eigenvectors with slower HOG feature extraction and SVM classification, achieving 81% accuracy while being 20% faster than using HOG alone. The objective of the project is to automatically identify the emotion expressed in a human face.

Uploaded by

Abhijeet Sarcar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
75 views

"Emotion Regognition System": A Project Report ON

This document is a project report submitted by four students - Abhijeet Sarcar, Anshul Anand, Ajeet Kumar, and Pradeep Kumar - for their Bachelor of Technology degree. It presents research on developing an emotion recognition system. The system utilizes techniques like Viola-Jones detection, Harris corner detection, PCA, LDA, HOG features, and SVMs to extract faces and facial features from images and classify seven fundamental human emotions. The hybrid approach combines initial classification using eigenvectors with slower HOG feature extraction and SVM classification, achieving 81% accuracy while being 20% faster than using HOG alone. The objective of the project is to automatically identify the emotion expressed in a human face.

Uploaded by

Abhijeet Sarcar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 29

A PROJECT REPORT

ON
“EMOTION REGOGNITION system”
Submitted in the partial fulfilment of the award
Of
BACHELOR OF TECHNOLOGY
Degree in
COMPUTER SCIENCE AND ENGINEERING (2021) submitted
by
Abhijeet Sarcar (1743110002)
Anshul Anand (1743110014)
Ajeet Kumar (1743110007)
Pradeep Kumar (1743110041)
under the supervision of
Mr. Vinay Kumar
(Associate Professor)

B.N. COLLEGE OF ENGINEERING & TECHNOLOGY, LUCKNOW


Affiliated to
Dr. A.P.J. ABDUL KALAM TECHNICAL UNIVERSITY, LUCKNOW
2020-2021
DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING

B.N. College of Engineering and Technology

CERTIFICATION
This is to certify that the project entitled “Emotion recognition
System” is carried by ABHIJEET SARCAR during year 2020 in the
partial fulfilment of the requirement for the award of Bachelor of
Technology from B. N. College of Engineering and Technology. This
project embodies result of the original work carried out by students
themselves and the contents of the project do not form the basis for
the award of any degree to the candidate or anybody else.

PROJECT GUIDE MR. VINAY KUMAR


Mr. SATYAM DUBEY HEAD OF DEPARTMENT
ASSISTANT PROFESSOR COMPUTER SCIENCE
DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING

B.N. College of Engineering and Technology

CERTIFICATION
This is to certify that the project entitled “Emotion recognition
System” is carried by ANSHUL ANAND during year 2020 in the partial
fulfilment of the requirement for the award of Bachelor of
Technology from B. N. College of Engineering and Technology. This
project embodies result of the original work carried out by students
themselves and the contents of the project do not form the basis for
the award of any degree to the candidate or anybody else.

PROJECT GUIDE MR. VINAY KUMAR


Mr. SATYAM DUBEY HEAD OF DEPARTMENT
ASSISTANT PROFESSOR COMPUTER SCIENCE
DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING
B.N. College of Engineering and Technology

CERTIFICATION
This is to certify that the project entitled “Emotion
recognition System” is carried by AJEET KUMAR during year
2020 in the partial fulfilment of the requirement for the
award of Bachelor of Technology from B. N. College of
Engineering and Technology. This project embodies result of
the original work carried out by students themselves and the
contents of the project do not form the basis for the award
of any degree to the candidate or anybody else.

PROJECT GUIDE MR. VINAY KUMAR


Mr. SATYAM DUBEY HEAD OF DEPARTMENT
ASSISTANT PROFESSOR COMPUTER SCIENCE
DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING

B.N. College of Engineering and Technology

CERTIFICATION
This is to certify that the project entitled “Emotion recognition System” is
carried by PRADEEP KUMAR during year 2020 in the partial fulfilment of the
requirement for the award of Bachelor of Technology from B. N. College of
Engineering and Technology. This project embodies result of the original work
carried out by students themselves and the contents of the project do not
form the basis for the award of any degree to the candidate or anybody else.

PROJECT GUIDE MR. VINAY KUMAR


Mr. SATYAM DUBEY HEAD OF DEPARTMENT
ASSISTANT PROFESSOR COMPUTER SCIENCE
INTRODUCTION
Humans share a universal and fundamental set of emotions which
are exhibited through consistent facial expressions. An algorithm
that performs detection, extraction, and evaluation of these facial
expressions will allow for automatic recognition of human emotion in
images and videos. Presented here is a hybrid feature extraction and
facial expression recognition method that utilizes Viola-Jones
cascade object detectors and Harris corner key-points to extract
faces and facial features from images and uses principal component
analysis, linear discriminant analysis, histogram-of-oriented-
gradients (HOG) feature extraction, and support vector machines
(SVM) to train a multi-class predictor for classifying the seven
fundamental human facial expressions. The hybrid approach allows
for quick initial classification via projection of a testing image on to a
calculated eigen vector, of a basis that has been specifically
calculated to emphasis the separation of a specific motion from
others. This initial step works well for five of the seven emotions
which are easier to distinguish. If further prediction is needed, then
the computationally slower HOG feature extraction is performed and
a class prediction is made with a trained SVM. Reasonable accuracy is
achieved with the predictor, dependent on the testing set and test
emotions. Accuracy is 81% with contempt, a very difficult-to-
distinguished motion, included as a target emotion and the run-time
of the hybrid approach is 20% faster than using the HOG approach
exclusively.

The emotions, set in simple words are what people feel. Emotional
aspects have huge impact on Social intelligence like communication
understanding, decision making and helps in understanding
behavioural aspect of human. Human faces provide various
information about emotions. As per psychological researcher, a
person expresses his emotions less by verbal talk and more by non-
verbal body posture and gestures. Emotion recognition or Affective
Computing (AC) being the AI related area imparts intelligence to
computers in recognizing human emotions. Emotion recognition is
proved a popular research area topic in few decades. The aim of this
paper is to report an illustrative and comprehensive study of most
popular emotion recognition methods, which are generally used in
emotion recognition problems. We are motivated by the lack of
detailed study of all possible techniques implementations in available
literature. This paper provides an up-to-date comprehensive survey
of techniques available for emotion recognition.

This paper discusses the application of feature extraction of facial


expressions with combination of neural network for the recognition
of different facial emotions (happy, sad, angry, fear, surprised,
neutral etc). Humans are capable of producing thousands of facial
actions during communication that vary in complexity, intensity, and
meaning. This paper analyses the limitations with existing system
Emotion recognition using brain activity. In this paper by using an
existing simulator I have achieved 97 percent accurate results and it
is easy and simplest way than Emotion recognition using brain
activity system. Purposed system depends upon human face as we
know face also reflects the human brain activities or emotions. In this
paper neural network has been used for better results. In the end of
paper comparisons of existing Human Emotion Recognition System
has been made with new one.

Emotion plays an important role in our daily lives. Ever since the 19th
century, experimental psychologists have attempted to understand
and explain human emotion. Despite an extensive amount of
research conducted by psychologists, anthropologists, and so
ciologists over the past 150 years, researchers still cannot agree on
the definition of emotion itself and have continued to try and devise
ways to measure emotional states. In this paper, we provide an
overview of the most prominent theories in emotional psychol ogy
(dating from the late 19th century to the present day), as well as a
summary of a number of studies which attempt to measure certain
aspects of emotion. This paper is organized chronologically; first with
an analysis of various uni-modal studies, followed by a review of
multi-modal research. Our findings suggest that there is insufficient
evidence to neither prove nor disprove the existence of coherent
emotional expression, both within subjects and between subjects.
Furthermore, the results seem to be heavily influenced by both
experimental conditions as well as by the theoretical assumptions
that underpin them.
OBJECTIVE AND MOTIVATION

The objective of face emotion recognition (FER) is identifying


emotions of a human. The emotion can be captured either from face
or from verbal communication. Psychological characteristics such as
heartbeat and blood Pressure, speech, hand gestures, body
movements, Facial expressions identify emotions of a person. Facial
emotion recognition is one of the useful tasks and can be used as a
base for many real-time applications. It can be used as a part of
many interesting and useful applications like Monitoring security,
treating patients in medical field, marketing research, E-learning etc.
We humans can easily identify the emotion of other humans without
any effort. Automatic detection of emotion of a human face is
important due to its use in real-time applications. The objective of
FER is to identify the emotion of a human face. That is given a face of
a human the system has to automatically identify the type of
emotion of the face as happy, anger, disgust, fear, happiness,
sadness, and surprise. Several studies have been conducted in this
area as there are large number of applications which directly or
indirectly uses FER. FER can be used as a part of many interesting and
useful applications like Monitoring security, treating patients in
medical field, marketing research, E-learning etc.
ABOUT THE PROJECT

Libraries used -

1. Flask : Flask is a micro web framework written in Python. It is


classified as a micro framework because it does not require
particular tools or libraries. It has no database abstraction layer,
form validation, or any other components where pre-existing
third-party libraries provide common functions. Flask was created
by Armin Ronacher of Pocoo, an international group of Python
enthusiasts formed in 2004. According to Ronacher, the idea was
originally an April Fool's joke that was popular enough to make
into a serious application. The name is a play on the earlier Bottle
framework.

2. Keras Preprocessing : Keras Preprocessing is the data


preprocessing and data augmentation module of the Keras deep
learning library. It provides utilities for working with image data,
text data, and sequence data. Keras Preprocessing is compatible
with Python 2.7-3.6 and is distributed under the MIT license.
Keras is a deep learning API written in Python, running on top of
the machine learning platform TensorFlow. It was developed with
a focus on enabling fast experimentation. Being able to go from
idea to result as fast as possible is key to doing good research.

Keras is a deep learning API written in Python, running on top of


the machine learning platform TensorFlow. It was developed with
a focus on enabling fast experimentation. Being able to go from
idea to result as fast as possible is key to doing good research.

3. Matplotlib: Matplotlib is a plotting library for the Python


programming language and its numerical mathematics extension
NumPy. It provides an object-oriented API for embedding plots
into applications using general-purpose GUI toolkits like Tkinter,
wxPython, Qt, or GTK. There is also a procedural "pylab" interface
based on a state machine (like OpenGL), designed to closely
resemble that of MATLAB, though its use is discouraged. SciPy
makes use of Matplotlib. Matplotlib was originally written by John
D. Hunter. Since then it has an active development community
and is distributed under a BSD-style license. Michael Droettboom
was nominated as matplotlib's lead developer shortly before John
Hunter's death in August 2012 and was further joined by Thomas
Caswell. Matplotlib 2.0.x supports Python versions 2.7 through
3.10. Python 3 support started with Matplotlib 1.2. Matplotlib 1.4
is the last version to support Python 2.6. Matplotlib has pledged
not to support Python 2 past 2020 by signing the Python 3
Statement. Pyplot is a Matplotlib module which provides a
MATLAB-like interface. Matplotlib is designed to be as usable as
MATLAB, with the ability to use Python, and the advantage of
being free and open-source.

4. NumPy : NumPy is a Python package. It stands for 'Numerical


Python'. It is a library consisting of multidimensional array objects
and a collection of routines for processing of array. Numeric, the
ancestor of NumPy, was developed by Jim Hugunin. Another
package Numarray was also developed, having some additional
functionalities. In 2005, Travis Oliphant created NumPy package
by incorporating the features of Numarray into Numeric package.
There are many contributors to this open source project.
5. TensorFlow : TensorFlow is the second machine learning
framework that Google created and used to design, build, and
train deep learning models. You can use the TensorFlow library
do to numerical computations, which in itself doesn’t seem all too
special, but these computations are done with data flow graphs.
In these graphs, nodes represent mathematical operations, while
the edges represent the data, which usually are multidimensional
data arrays or tensors, that are communicated between these
edges.

6. OpenCV : OpenCV is a huge open-source library for computer


vision, machine learning, and image processing. OpenCV supports
a wide variety of programming languages like Python, C++, Java,
etc. It can process images and videos to identify objects, faces, or
even the handwriting of a human. When it is integrated with
various libraries, such as Numpy which is a highly optimized
library for numerical operations, then the number of weapons
increases in your Arsenal i.e. whatever operations one can do in
Numpy can be combined with OpenCV.

7. Python Pillow : Pillow is built on top of PIL (Python Image


Library). PIL is one of the important modules for image processing
in Python. However, the PIL module is not supported since 2011
and doesn’t support python 3. Pillow module gives more
functionalities, runs on all major operating system and support
for python 3. It supports wide variety of images such as “jpeg”,
“png”, “bmp”, “gif”, “ppm”, “tiff”. You can do almost anything on
digital images using pillow module. Apart from basic image
processing functionality, including point operations, filtering
images using built-in convolution kernels, and color space
conversions.
8. Pandas : Pandas is an open source 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
distributions like ActiveState’s ActivePython. Pandas makes it
simple to do many of the time consuming, repetitive tasks
associated with working with data, including: Data cleansing, Data
fill, Data normalization, Merges and joins, Data visualization,
Statistical analysis, Data inspection, Loading and saving data, and
much more.

9. Werkzeug : Werkzeug is a comprehensive WSGI web application


library. It began as a simple collection of various utilities for WSGI
applications and has become one of the most advanced WSGI
utility libraries.

It includes:
An interactive debugger that allows inspecting stack traces and
source code in the browser with an interactive interpreter for any
frame in the stack.
A full-featured request object with objects to interact with
headers, query args, form data, files, and cookies.
A response object that can wrap other WSGI applications and
handle streaming data.
A routing system for matching URLs to endpoints and generating
URLs for endpoints, with an extensible system for capturing
variables from URLs.
HTTP utilities to handle entity tags, cache control, dates, user
agents, cookies, files, and more.
A threaded WSGI server for use while developing applications
locally.
A test client for simulating HTTP requests during testing without
requiring running a server.

10. Urllib3 : Urllib3 is a powerful, user-friendly HTTP client for


Python. Much of the Python ecosystem already uses urllib3 and
you should too.

urllib3 brings many critical features that are missing from the
Python standard libraries:
Thread safety.
Connection pooling.
Client-side SSL/TLS verification.
File uploads with multipart encoding.
Helpers for retrying requests and dealing with HTTP redirects.
Support for gzip, deflate, and brotli encoding.
Proxy support for HTTP and SOCKS.
100% test coverage.
Methodology

Human Emotion:
Emotion is an important aspect in the interaction and communication between
people. Even though emotions are intuitively known to everybody, itis hard to
define emotion. The Greek philosopher Aristotle thought of emotion as a
stimulus that evaluates experiences based on the potential for gain or
pleasure. Years later, in the seventeenth century, Descartes considered
emotion to mediate between stimulus and response [2]. Nowadays there is
still little consensus about the definition of emotion. Kleinginna and Kleinginna
gathered and analyzed 92 definitions of emotion from literature

present that day. They conclude that there is little consistency between
different definitions and suggested the following comprehensive definition
Emotion is a complex set of interactions among subjective and objective
factors, mediated by neural/hormonal systems, which can:

1. Give rise to affective experiences such as feelings of arousal,


pleasure/displeasure.

2. Generate cognitive processes such as emotionally relevant perceptual


effects, appraisals, labelling processes

3. Activate widespread physiological adjustments to the arousing conditions;

4. Lead to behaviour that is often, but not always, expressive, goal directed,
and adaptive.

This definition shows the different sides of emotion. On the one hand emotion
generates specific feelings and influences someone‘s behavior. This part of
emotion is well knownand is in many cases visible to a person himself or to
the outside world. On the other hand emotion also adjusts the state of the
human brain, and directly or indirectly influences several processes [2]. Fig2
is showing different Human emotions which are use able in order to achieve
our goal
Fig.: Different human emotions

In spite of the difficulty of precisely defining it, emotion is omnipresent and an


important factor in human life. People’s moods heavily influence their way of
communicating, but also their acting and productivity. Imagine two car
drivers, one being happy and the other being very mad. They will be driving
totally different. Emotion also plays a crucial role in all-day communication.
One can say a word like `OK' in a happy way, but also with disappointment or
sarcasm. In most communication this meaning is interpreted from the tone of
the voice or from non-verbal communication. Other emotions are in general
only expressed by body language, like boredom

A large part of communication is done nowadays by computer or other


electronic devices. But this interaction is a lot different from the way human
beings interact. Most of the communication between human beings involves
non-verbal signs, and the social aspect of this communication isimportant.
Humans also tend to include this social aspect when communicating with
computers

SCOPE
i. This work deals with measuring the facial expressions of human beings
ii. It does not deal with rest of body of the humans
iii .As there exist some methods which do the same job they are also
considered in this research work.
iv. Since it is not feasible to run these algorithms in real environment,
therefore a simulator is developed which will simulate the proposed work.
v. Different type of tests will be implemented using proposed strategy.
vi. Visualization of the experimental results and drawing appropriate
performance analysis.
vii. Appropriate conclusion will be made based upon performance analysis.
viii. For future work suitable future directions will be drawn considering
limitations of existing work.

Throughout the research work emphasis has been on the use of either open
source tools technologies or licensed software

System Diagram:
System design shows the overall design of system. In this section we discuss in detail
the design aspects of the system:
Face detection:
Face Detection is useful in detection of facial image. Face Detection is
carried out in training dataset using Haar classifier called Voila-Jones
face detector and implemented through Opencv. Haar like features
encodes the difference in average intensity in different parts of the image
and consists of black and white connected rectangles in which the value
of the feature is the difference of sum of pixel values in black and white
region

Feature Extraction:
Selection of the feature vector is the most important part in a
pattern classification problem. The image of face after pre-
processing is then used for extracting the important features.
The inherent problems related to image classification include
the scale, pose, translation and variations in illumination level.
The important features are extracted using LBP algorithm
which is described below:
CNN
1. What is CNN ?
Computer vision is evolving rapidly day-by-day. Its one of the reason
is deep learning. When we talk about computer vision, a term
convolutional neural network( abbreviated as CNN) comes in our
mind because CNN is heavily used here. Examples of CNN in
computer vision are face recognition, image classification etc. It is
similar to the basic neural network. CNN also have learnable
parameter like neural network i.e, weights, biases etc.

2. Why should we use CNN ?


Problem with Feedforward Neural Network
Suppose you are working with MNIST dataset, you know each image
in MNIST is 28 x 28 x 1(black & white image contains only 1
channel). Total number of neurons in input layer will 28 x 28 = 784,
this can be manageable. What if the size of image is 1000 x 1000
which means you need 10⁶ neurons in input layer. Oh! This seems a
huge number of neurons are required for operation. It is
computationally ineffective right. So here comes Convolutional
Neural Network or CNN. In simple word that CNN does is, it extracts
the features of the image and convert it into lower dimension without
loosing its characteristics. In the following example you can see that
initial the size of the image is 224 x 224 x 3. If you proceed without
convolution then you need 224 x 224 x 3 = 100, 352 numbers of
neurons in input layer but after applying convolution you input tensor
dimension is reduced to 1 x 1 x 1000. It means you only need 1000
neurons in first layer of feedforward neural network.
Fig. Downsampling

3. Few Definitions
There are few definitions you should know before understanding CNN

3.1 Image Representation

Thinking about images, its easy to understand that it has a height and width, so
it would make sense to represent the information contained in it with a two
dimensional structure (a matrix) until you remember that images have colors,
and to add information about the colors, we need another dimension, and that
is when Tensors become particularly helpful.

Images are encoded into color channels, the image data is represented into
each color intensity in a color channel at a given point, the most common one
being RGB, which means Red, Blue and Green. The information contained into
an image is the intensity of each channel color into the width and height of the
image, just like this
Fig. RGB representation of a image

So the intensity of the red channel at each point with width and height can be
represented into a matrix, the same goes for the blue and green channels, so we
end up having three matrices, and when these are combined they form a tensor.

3.2 Edge Detection

Every image has vertical and horizontal edges which actually combining to
form a image. Convolution operation is used with some filters for detecting
edges. Suppose you have gray scale image with dimension 6 x 6 and filter of
dimension 3 x 3(say). When 6 x 6 grey scale image convolve with 3 x 3 filter, we
get 4 x 4 image. First of all 3 x 3 filter matrix get multiplied with first 3 x 3 size
of our grey scale image, then we shift one column right up to end , after that
we shift one row and so on.

Convolution operation
The convolution operation can be visualized in the following way. Here our image dimension
is 4 x 4 and filter is 3 x 3, hence we are getting output after convolution is 2 x 2.

If we have N x N image size and F x F filter size then after convolution result will be

(N x N) * (F x F) = (N-F+1)x(N-F+1)(Apply this for above case)

3.3 Stride and Padding


To maintain the dimension of output as in input , we use padding. Padding is a
process of adding zeros to the input matrix symmetrically. In the following
example, the extra grey blocks denote the padding. It is used to make the
dimension of output same as input.

Let say ‘p’ is the padding

Initially(without padding)

(N x N) * (F x F) = (N-F+1)x(N-F+1)---(1)

After applying padding

After applying padding

If we apply filter F x F in (N+2p) x (N+2p) input matrix with padding, then we


will get output matrix dimension (N+2p-F+1) x (N+2p-F+1). As we know that
after applying padding we will get the same dimension as original input
dimension (N x N). Hence we have,
(N+2p-F+1)x(N+2p-F+1) equivalent to NxN
N+2p-F+1 = N ---(2)
p = (F-1)/2 ---(3)

The equation (3) clearly shows that Padding depends on the dimension of filter.

4. Layers in CNN
There are five different layers in CNN

 Input layer

 Convo layer (Convo + ReLU)

 Pooling layer

 Fully connected(FC) layer

 Softmax/logistic layer

 Output layer

Different layers of CNN

4.1 Input Layer


Input layer in CNN should contain image data. Image data is represented by three
dimensional matrix as we saw earlier. You need to reshape it into a single column. Suppose
you have image of dimension 28 x 28 =784, you need to convert it into 784 x 1 before
feeding into input. If you have “m” training examples then dimension of input will be (784,
m).
4.2. Convo Layer
Convo layer is sometimes called feature extractor layer because features of the image are get
extracted within this layer. First of all, a part of image is connected to Convo layer to perform
convolution operation as we saw earlier and calculating the dot product between receptive
field(it is a local region of the input image that has the same size as that of filter) and the
filter. Result of the operation is single integer of the output volume. Then we slide the filter
over the next receptive field of the same input image by a Stride and do the same operation
again. We will repeat the same process again and again until we go through the whole image.
The output will be the input for the next layer.

Convo layer also contains ReLU activation to make all negative value to zero.

4.3. Pooling Layer

Source : CS231n Convolutional Neural Network

Pooling layer is used to reduce the spatial volume of input image after convolution. It is used
between two convolution layer. If we apply FC after Convo layer without applying pooling or
max pooling, then it will be computationally expensive and we don’t want it. So, the max
pooling is only way to reduce the spatial volume of input image. In the above example, we
have applied max pooling in single depth slice with Stride of 2. You can observe the 4 x 4
dimension input is reduce to 2 x 2 dimension.

There is no parameter in pooling layer but it has two hyperparameters — Filter(F) and
Stride(S).

In general, if we have input dimension W1 x H1 x D1, then

W2 = (W1−F)/S+1

H2 = (H1−F)/S+1
D2 = D1

Where W2, H2 and D2 are the width, height and depth of output.

4.4. Fully Connected Layer(FC)


Fully connected layer involves weights, biases, and neurons. It connects neurons in one layer
to neurons in another layer. It is used to classify images between different category by
training.

4.5. Softmax / Logistic Layer


Softmax or Logistic layer is the last layer of CNN. It resides at the end of FC layer. Logistic
is used for binary classification and softmax is for multi-classification.

4.6. Output Layer


Output layer contains the label which is in the form of one-hot encoded.

Now you have a good understanding of CNN. Let’s implement a CNN in Keras.

What are EigenFaces ?


Eigenfaces are images that can be added to a mean (average) face to create new
facial images. We can write this mathematically as,

where,

is a new face.
is the mean or the average face,
is an EigenFace,
are scalar multipliers we can choose to create new faces. They can be positive
or negative.
Figure 2 : On the left is the mean image. On the right is a new face produced by adding 10 Eigenfaces
with different weights (shown in center).

Eigenfaces are calculated by estimating the principal components of the dataset


of facial images. They are used for applications like Face Recognition and
Facial Landmark Detection.

How to calculate EigenFaces?


To calculate EigenFaces, we need to use the following steps.
1. Obtain a facial image dataset : We need a collection of facial images
containing different kinds of faces. In this post, we used about 200
images from CelebA.
2. Align and resize images : Next we need to align and resize images so the
center of the eyes are aligned in all images. This can be done by first
finding facial landmarks. In this post, we used aligned images supplied in
CelebA. At this point, all the images in the dataset should be the same
size.
3. Create a data matrix: Create a data matrix containing all images as a row
vector. If all the images in the dataset are of size 100 x 100 and there are
1000 images, we will have a data matrix of size 30k x 1000.
4. Calculate Mean Vector [Optional]: Before performing PCA on the data,
we need to subtract the mean vector. In our case, the mean vector will
be a 30k x 1 row vector calculated by averaging all the rows of the data
matrix. The reason calculating this mean vector is not necessary for
using OpenCV’s PCA class is because OpenCV conveniently calculates the
mean for us if the vector is not supplied. This may not be the case in
other linear algebra packages.
5. Calculate Principal Components: The principal components of this data
matrix are calculated by finding the Eigenvectors of the covariance
matrix. Fortunately, the PCA class in OpenCV handles this calculation for
us. We just need to supply the datamatrix, and out comes a matrix
containing the Eigenvectors
6. Reshape Eigenvectors to obtain EigenFaces: The Eigenvectors so
obtained will have a length of 30k if our dataset contained images of size
100 x 100 x 3. We can reshape these Eigenvectors into 100 x 100 x 3
images to obtain EigenFaces.

Fisher faces
Fisher faces method learns a class specific transformation matrix, so, they do
not capture illustrations as obviously as the Eigenfaces method.

Discriminant analysis instead finds the facial feature to discriminate between


the persons. Its important to mention that the performance of the Fisher faces
heavily depends upon input data as well.

Fisher faces allows reconstruction of the projected image, just like Eigen Faces
did, but since we only identified the features to distinguish between subjects, we
cannot expect a nice reconstruction of original image. Fisher faces is especially
useful when facial images have large variations in illuminations and facial
expressions.
SYSTEM REQUIREMENTS

MIN. SYSTEM REQUIREMENTS

Processor: i3 or higher

Graphics Card: Min. 512mb External Graphics Card

OS: Windows 10

RAM: 4GB

Web Camera: Needed for face reading

Software Requirement: Python 3.9.6

Libraries Needed: Flask==1.1.2


Keras-Preprocessing==1.1.0
matplotlib==3.3.3
opencv-python==4.4.0.46
pandas==1.1.5
Pillow>=8.0.1
tensorflow>=2.3.0
numpy==1.19.2
urllib3>=1.26.2
werkzeug==1.0.1

You might also like