I have embarked on a journey to learn deep learning. โFor the things we have to learn before we can do them, we learn by doing them.โ โ Aristotle.
In my previous article, we learned about face detection using MTCNN. Now, we will try to recognize the faces extracted by MTCNN. I have compiled a dataset of 30 Bollywood celebrities for our face recognition task. Every star has around ten training and ten validation images. FaceNet is a face recognition system developed in 2015 by Google researchers in a paper titled โFaceNet: A Unified Embedding for Face Recognition and Clustering.โ Given a picture of a face with input dimensions (160, 160, 3), FaceNet will extract high-quality features from the face and predict a 128 element vector representation called face embeddings. Then, we will use Support-Vector Machine to classify these face embeddings into respective Bollywood celebrities.
First, we will extract faces from all our celebrity images using MTCNN and save the extracted face pixel arrays in uncompressed .npz format. Next, make sure to split celebrity images into train and validation folders.
Thatโs it. The bollywood-data.npz contains a list of all faces that MTCNN detected in our celebrity dataset.
Next, we will transform the extracted faces into face embedding using FaceNet. Finally, we will save all our face embeddings for into bollywood-embeddings.npz.
After extracting face embeddings, we will build a classifier using Support Vector Machine to classify face embeddings to respective labels. We can choose any multi-class classifier, including building our Neutral Network.
I choose Support Vector Machine due to its simplicity and popularity in other machine learning blogs for the face recognition step.
We now evaluate our model using our test images. Finally, we will plot our results to have visual confirmation of SVM model performance on test images.
Tada ๐ We have our face recognition code. How well the model performs depends on the size of our dataset. There are many other alternative models available, and we can always plug better models and experiment to see if we get better results.