Face Recognition Project based on Deep Learning
Today Deep Learning is continuosly impacting our lives and making it more easier.
In Deep Learning a Convolutional neural network (CNN) is a class of deep neural networks most commonly applied to analyzing images like image classification.
CNNs consists of multilayer perceptrons. Multilayer perceptrons usually mean fully connected networks, that is, each neuron in one layer is connected to all neurons in the next layer.
Using these concepts of CNN ,I have made a project which analyzes a face using the pre-trained models' weights , classifies them into various classes and recognizes a given face based on the class to which it belongs.
- I have used the pre-trained model of MobileNet which consists of 86 different layers making the prediction more accurate and a python library Keras using tensorflow as backend to create this project.
- Next we fix the input shape of the images as MobileNet allows a fixed size of image to be trained. We also make the layers of the model non-trainable as we intend to use weights already found out to add a new feature in the existing model.
- Then we create the top or the head of the model that will be placed on top of all the bottom layers. We create this inside a function 'lw' and define four dense layers , three with activation function 'relu' and the last one with activation function 'softmax'.
- Next we import all the necessary functions from keras that we require in making the different layers of the model.
- Now we need to get the dataset classified into various classes for this we create a folder faces=>faces=>1. train 2. validation=> 1. face1(adi) 2. face2(mansi)
- Next we use Data Augmentation to increase our dataset and by using the function ImageDataGenerator. Then we set our batch size and load the number of images in each class.
- Finally we train our model for the new features by creating a checkpoint and an early stop for the model. Then we put our call backs into a callback list. We use a very small learning rate of 0.001, enter the number of training and validation samples and lastly train our model through 5 epochs.
- We get an accuracy of 84.51%. Now its the time to predict the output using opencv and numpy libraries of python we load the image from the validation folder and predict the class of the image.
And here are the Predictions !!
It has correctly predicted the class of the images.