Before we get started looking at the rich array of tools OpenIMAJ offers for working with faces, lets first look at how we can implement one of the earliest successful face recognition algorithms called "Eigenfaces". The basic idea behind the Eigenfaces algorithm is that face images are "projected" into a low dimensional space in which they can be compared efficiently. The hope is that intra-face distances i. Fundamentally, this projection of the image is a form of feature extraction, similar to what we've seen in previous chapters of this tutorial. Unlike the extractors we've looked at previously however, for Eigenfaces we actually have to "learn" the feature extractor from the image data.
|Published (Last):||23 June 2019|
|PDF File Size:||11.54 Mb|
|ePub File Size:||7.21 Mb|
|Price:||Free* [*Free Regsitration Required]|
Download the full code here. Before discussing principal component analysis, we should first define our problem. Face recognition is the challenge of classifying whose face is in an input image. With face recognition, we need an existing database of faces. There are several downsides to this approach. First of all, if we have a large database of faces, then doing this comparison for each face will take a while! The larger our dataset, the slower our algorithm. But more faces will also produce better results!
We want a system that is both fast and accurate. We can train our network on our dataset and use it for our face recognition task. If we had a single image, we would have to flatten it out into a single vector to feed into our neural network as input. For large image sizes, this might hurt speed! The previous section motivates our reason for using a dimensionality reduction technique. Dimensionality reduction is a type of unsupervised learning where we want to take higher-dimensional data, like images, and represent them in a lower-dimensional space.
These plots show the same data, except the bottom chart zero-centers it. In our simple case, dimensionality reduction will reduce these data from a 2D plane to a 1D line. If we had 3D data, we could reduce it down to a 2D plane or even a 1D line.
For example, in our above data, if we wanted to project our points onto the x-axis, then we pretend each point is a ball and our flashlight would point directly down or up perpendicular to the x-axis and the shadows of the points would fall on the x-axis.
In our simple 2D case, we want to find a line to project our points onto. After we project the points, then we have data in 1D instead of 2D! Similarly, if we had 3D data, we want to find a plane to project the points down onto to reduce the dimensionality of our data from 3D to 2D. The different types of dimensionality reduction are all about figuring out which of these hyperplanes to select: there are an infinite number of them!
The idea behind PCA is that we want to select the hyperplane such that when all the points are projected onto it, they are maximally spread out. However, if we pick a line that cuts through our data diagonally, that is the axis where the data would be most spread! The longer blue axis is the correct axis! If we were to project our points onto this axis, they would be maximally spread!
But how do we figure out this axis? Using this approach, we can take high-dimensional data and reduce it down to a lower dimension by selecting the largest eigenvectors of the covariance matrix and projecting onto those eigenvectors. There are other dimensionality techniques, such as Linear Discriminant Analysis, that use supervised learning and are also used in face recognition, but PCA works really well!
How does this relate to our challenge of face recognition? We can conceptualize our images as points in -dimensional space. This will help speed up our computations and be robust to noise and variation.
This is why we run an out-of-the-box face detection algorithm, such as a cascade classifier trained on faces, to figure out what portion of the input image has a face in it. When we have that bounding box, we can easily slice out that portion of the input image and use eigenfaces on that slice. Feel free to substitute your own dataset! The wider variety of faces you use, the better the recognizer will do. The easiest way to create a dataset for face recognition is to create a folder for each person and put the face images in there.
Then use the folder names to disambiguate classes. Using this approach, you can use your own images. Luckily, scikit-learn can automatically load our dataset for us in the correct format. We can call a function to load our data. The argument to our function just prunes all people without at least faces, thus reducing the number of classes. Then we can extract our dataset and other auxiliary information. Finally, we split our dataset into training and testing sets.
We have to select the number of components, i. Whitening just makes our resulting data have a unit variance, which has been shown to produce better results. We can apply the transform to bring our images down to a dimensional space. This is so we can better generalize to unseen data. Additionally, we use early stopping. Essentially, our optimizer will monitor the average accuracy for the validation set for each epoch. Consider the above chart.
We notice overfitting when our validation set accuracy starts to decline. At that point, we immediately stop training to prevent overfitting. Finally, we can make a prediction and use a function to print out an entire report of quality for each class. Notice there is no accuracy metric. Instead, we see precision, recall, f1-score, and support. The support is simply the number of times this ground truth label occurred in our test set, e.
The F1-Score is actually just computed from the precision and recall scores. Precision and recall are more specific measures than a single accuracy score. A higher value for both is better. Another thing interesting thing to visualize is are the eigenfaces themselves. Remember that PCA produces eigenvectors.
We can reshape those eigenvectors into images and visualize the eigenfaces. Now that we have a smaller representation of our faces, we apply a classifier that takes the reduced-dimension input and produces a class label.
For our classifier, we used a single-layer neural network. Face recognition is a fascinating example of merging computer vision and machine learning and many researchers are still working on this challenging problem today!
This project is aim to implement facial recognition using Singular Value Decomposition SVD that has being widely used as the basis of facial recognition algorithms. The eigen-vectors of SVD over the facial dataset are often regarded as eigenfaces. Due to human resources, time constraint, and level of experiences, this project does not try to innovate from the baseline method. The core of this project is to learn the algorithm and implemented it. The environment which my project runs on is.
Face Recognition with Eigenfaces
The main purpose behind writing this tutorial was to provide a more detailed set of instructions for someone who is trying to implement an eigenface based face detection or recognition systems. It is assumed that the reader is familiar at least to some extent with the eigenface technique as described in the original M. Turk and A. Pentland papers see "References" for more details. The idea behind eigenfaces is similar to a certain extent to the one behind the periodic signal representation as a sum of simple oscillating functions in a Fourier decomposition. The technique described in this tutorial, as well as in the original papers, also aims to represent a face as a linear composition of the base images called the eigenfaces. To download the software shown in video for bit x86 platform, click here.