Facial Recognition Model training takes a lot of time for training the weights. So,I used the concept of transfer learning to train my model from a pre trained MobileNet model to save the time. All the features extracted by this model is similar so it takes less time to train model again .
For my model I freezed the layers already present in the model and added customized fully connected layer(fcl) in the end. This reduced the amount of dataset to be provided to my model.
I used dataset having faces of five celebrities separated in training and testing(validation) images folders .
- The first step was to reload MobileNet model. In variable MobileNet I added the weights but excluded the top layer by using include_top= False. Then the layers were freezed and made untrainable by using layer.trainable=False . The layers we then printed with their names and showing if they are trainable or not but since we have freezed them so model shows False succeeding their names.
2. The next step was to create customized FCL and and attach it on top of the freezed bottom layers. For this the function used was head_model having customized layers.
3. For better model training we use data augmentation to process out image dataset.
4. Model is trained by performing 5 epochs and the accuracy achieved by my model is 93.21%.
5. testing our model by providing random images from test images.
The predictions can be further improved by altering our customized layers and providing a bigger dataset to our model.
The code is available at: https://github.com/ishajain140/face_recognition_model_mobilenet.git