## Blog: How AI recognizes a Face?

How AI recognizes a Face?

First of all its machine learning and not AI which recognizes faces, Machine learning is a subset of Artificial Intelligence so-called AI, AI has two subsets

- Machine Learning
- Deep Learning

The facial recognition algorithm is formed using both techniques simultaneously

**Face Recognition Methods ( Not Digging Deeper into concepts ):-**

There are different methods for face recognition, which are as follows-

*1.Geometric Based / Template Based*

*2.Piecemeal / Wholistic*

*3.Appearance-Based / Model-Based*

*4.Template / Statistical / Neural Networks Based*

*4.1.Template Matching*

In template matching the patterns are represented by samples, models, pixels, textures, etc. The recognition function is usually a correlation or distance measure.

*4.2.Statistical Approach*

In the Statistical approach, the patterns expressed as features. The recognition function in a discriminant function. Each image represented regarding d features. Therefore, the goal is to choose and apply the right statistical tool for extraction and analysis.

There are many statistical tools, which used to face recognition. These analytical tools used in two or more groups or classification methods. These tools are as follows-

*4.2.1. Principal Component Analysis [PCA]**4.2.2. Discrete Cosine Transform [DCT]**4.2.3. Linear Discriminant Analysis [LDA]**4.2.4. Locality Preserving Projections [LPP]**4.2.5. Gabor Wavelet**4.2.6. Independent Component Analysis [ICA]**4.2.7. Kernel PCA**4.3. Neural Networks*

Neural Network has continued to use pattern recognition and classification. Kohonen was the first to show that a neuron network could be used to recognize aligned and normalized faces. There are methods, which perform feature extraction using neural networks. There are many methods, which combined with tools like PCA or LCA and make a hybrid classifier for face recognition. These are like Feed Forward Neural Network with additional bias, Self-Organizing Maps with PCA, and Convolutional Neural Networks with multi-layer perception, etc. These can increase the efficiency of the models.

Deep Neural Network for Face Recognition

*4.3.1.Neural Networks with Gabor Filters*

The algorithm achieves face recognition by implementing a multilayer perceptron with a back-propagation algorithm. Firstly, there is a preprocessing step. Each image normalized in phases of contrast and illumination. Then each image is processed through a Gabor filter. The Gabor filter has five orientation parameters and three spatial frequencies, so there are 15 Gabor wavelengths.

*4.3.2.Neural Networks and Hidden Markov Models*

Hidden Markov Models are a statistical tool used in face recognition. They have used in conjunction with neural networks. It generated in a neural network that trains pseudo 2D HMM. The input of this 2D HMM process is the output of the ANN, and It provides the algorithm with the proper dimensionality reduction.

*4.3.3.Fuzzy Neural Networks*

The fuzzy neural networks for face recognition introduce in 2009. In this a face recognition system using a multilayer perceptron. The concept behind this approach is to capture decision surfaces in nonlinear manifolds a task that a simple MLP can hardly complete. The feature vectors are obtained using Gabor wavelength transforms.

**How the Face Recognition works**

There are many ways to face recognition. Here we use OpenCV for face recognition. In face recognition, the image first prepared for preprocessing and then trained the face recognizer to recognize the faces. After teaching the recognizer, we test the recognizer to see the results. The OpenCV face recognizer are of three types, which are as follows-

**1.EigenFaces Face Recognizer**

EigenFaces face recognizer views at all the training images of all the characters as a complex and try to deduce the components. These components are necessary and helpful (the parts that grab the most variance/change) and discard the rest of the images, This way it not only extracts the essential elements from the training data but also saves memory by rejecting the less critical segments.

**2.FisherFaces Recognizer**

Fisherfaces algorithm, instead of obtaining useful features that represent all the faces of all the persons, it removes valuable features that discriminate one person from the others. This features of one person do not dominate over the others, and you have the features that distinguish one person from the others.

**3.Local Binary Patterns Histograms**

We know that Eigenfaces and Fisherfaces are both affected by light and in real life; we cannot guarantee perfect light conditions. LBPH face recognizer is an improvement to overcome this drawback. The idea is not to find the local features of an image. LBPH algorithm tries to find the local structure of an image, and it does that by comparing each pixel with its neighboring pixels.

*Source: Artificial Intelligence on Medium*