In this article I am going to create a face-recognition model using the concept of Transfer learning and VGG16 over a pre-trained model. Here I am using MobileNet. Before we start let us understand what is Transfer Learning and VGG16.
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.
The main advantage of transfer learning is that it decreases the time that take to develop and train a model by reusing the existing model as starting point.
VGG16 is a convolutional neural network model proposed by K. Simonyan and A. Zisserman from the University of Oxford in the paper “Very Deep Convolutional Networks for Large-Scale Image Recognition”. The model achieves 92.7% top-5 test accuracy in ImageNet, which is a dataset of over 14 million images belonging to 1000 classes.
Now let’s create the code.
Step 1: First we need to collect the dataset. Here I am using a python code to collect the image, crop it and then will resize it as per the need and also store it inside a folder.
Step 2: In this step we will create the for transfer learning. Let’s do step by step.
- First import required Modules.
2. In this step we will create the model using the weight of VGG16.
3. Freezing the top layer.
4. Loading the dataset.
5. Compile the model.
Step 3: Code to detect the face.