MLOps Task 4: Face Recognition using Transfer Learning

Original article was published on Deep Learning on Medium


MLOps Task 4: Face Recognition using Transfer Learning

Face Detection

Face Recognition is one of the most widely used applications of Machine Learning/Deep Learning. There are a number of algorithms available in the market, all having some pros and some cons of their own, to detect faces on the basis of a number of features.
But most of the times, we need to create the model all from scratch and need to train all the layers by ourselves, which in case of a large data set, is a tedious task. There comes the role of advanced technologies like Transfer Learning.

Transfer learning is a machine learning method where a model developed for a task is reused as the starting point for a model on a second task. So, we can used a pre-trained model for starting the training some part of our model, which saves us a lot of time and effort.
The basic difference between conventional Machine Learning Algorithms and Transfer Learning is that the use of pre-trained models that have been used for another task to jump start the development process on a new task or problem. That’s why Transfer Learning is so powerful and must be used.

This brings to my 4th Task of MLOps which is described as:

Create a project using transfer learning solving various problems like Face Recognition, Image Classification, using existing Deep Learning models like VGG16, VGG19, ResNet, etc.

Now, for illustrating the power of Transfer Learning, I chose the application of Face Detetction because it is a data-intensive application.

For using as an existing Deep Learning model, I have used MobileNet.

MobileNets are a family of mobile-first computer vision models for TensorFlow, designed to effectively maximize accuracy while being mindful of the restricted resources for an on-device or embedded application. It is an efficient Convolutional Neural Network, which has significant effectiveness in object detection.

Now, moving on the task, for this task of Face Detection using MobileNet, I created datasets for faces of two people, me and my friend, captured using live camera using Computer Vision . I captured 50 photos for both of us for training the model and then 5 photos each for testing the model. The data set might be a little small, but is sufficient given it is for detecting only two faces.

50 Images for Training
5 Images for Testing

Now we will load the MobileNet model and various layers and then add an additional layer which is from our data thus making a complete model .Then we will train our model with the data.

Loading the MobileNet Model