Face Recognition Model (using MobileNet)

Isha Jain
3 min readMay 19, 2020

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 .

training and validation images are stored in respective folders
  1. 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.
Reloading MobileNet model and freezing the layers

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.

making customized layer and attaching with model
summary of model shows last five layers added by us

3. For better model training we use data augmentation to process out image dataset.

data augmentation performed

4. Model is trained by performing 5 epochs and the accuracy achieved by my model is 93.21%.

training model

5. testing our model by providing random images from test images.

prediction 1 (correct)
prediction 2 (false prediction)

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

--

--

Isha Jain

Cloud DevOps enthusiast who loves to integrate different tools to solve challenges.