Face Recognition Model
Training a model from scratch requires a very large dataset and takes a lot of time to train. The solution to this is using a pre-trained model since all the extracted features from images are similar (edges, circles, lines, etc.).So a pre-trained model converge fastly because his weights are already optimized , save you much time AND you don’t need a large dataset to train it to learn your data.
In this task we have to create a face recognition model so the best and efficient approach is to use transfer learning concept and to use this concept we require a pre-trained model so in my case I have used VGG16 convolutional neural network.
So for face recognition as we know that VGG16 does not contain our images so it can't recognize us , so for this we have to provide our own dataset which will contain our images.
So first step is to create a dataset of our images. So here we will use concept of openCV library. We will write a python code to take images and store in a folder.
So first of all we have to create folders shown in the image for training and test dataset.
This can have folders of multiple people as in my case I have created this model for myself and my sister. So two separate folders we have created.
Now we have to write code for collecting images. In my case I have taken 6000 images each of me and my sister which I will divide in 4:1 ratio that is 4800 images for training dataset and 1200 images for test dataset.
Transfer learning is a method through which we can use the weights of the pre-trained model to customize the network and train it on our custom dataset. Here we use the concept of freezing the layers that is we will tell the pre-trained network( deep neural network ) that you don't have to train the whole network for our new dataset just use your knowledge of the previous dataset because all the images are same. Here what changes we have to make in pre-created network is that we will not include the last layer of the model that is the output layer, instead we will include our own custom FCL( fully connected layer ) to train our dataset and at the end of our FCL we will add one output layer then we will combine our FCL with the pre-trained network.
Now once we have collected the dataset now we have to train the model.On training the model we will get to know about various layers of the model
Now we have to freeze all the layers and add the layer we created.
Now we have to train our pre-trained model with new dataset by running epochs in my case I have done 4 epochs. Here we are using loss function as loss = 'categorical_crossentropy' because it is multi classification data. We have used optimizer RMSprop(lr = 0.001) with learning rate as 0.001 and accuracy using metrics
And I am getting a good accuracy of around 99 percent
Now we have to make our model ready for testing.
Now I have taken 3 test cases to check for my Face Detection model and I got correct result.
So with this we come to the end of task and i want to thank Vimal Sir for giving us a industry level projects as by practising this will make our base stronger for future.
If you have any query related to task feel free to ask me.