Face Recognition using Transfer Learning and using VGG16
What is transfer learning ?
- Transfer learning is basically taking a model already trained on a large dataset and transfer its knowledge to a smaller dataset.
- In this picture the difference between training a model from scratch and with transfer learning is very much clear.
- For object recognition with a CNN, we freeze the early convolutional layers of the network and only train the last few layers which make a prediction.
- In this example we are going to use weights of pretrained model VGG16.
Architecture of VGG16 :
Problem Statement :
We have to train a model with the faces of family members using transfer learning and weights of vgg16 model.
1.Collecting dataset :
I have captured greyscale(black and white) images.So,that there will be less noise in data.
Also,used keras_preprocessing module to generate images from ImageDataGenerator() function which are coloured images .
2. Using Pre trained vgg16:
- For training CNN model with the weights of vgg16 we have to first import/load weights of imagenet. As we are going to tune vgg model to add our own layers at the end, so we didn't include top layer.
The advantages of VGG are :
- It is a very good architecture for benchmarking on a particular task.
- Also, pre-trained networks for VGG are available freely on the internet, so it is commonly used out of the box for various applications.
- Now, will add new layers in order to achive fine tuning.
- Now we have to connect new layers (fine tuning) to the layers of vgg16 model.
- As collected data is very small to train the model. Using concept of augmented images I have expanded my dataset by using methods like crop, resize, zoom, rotate.
- At last we have to train our model using concept of transfer learning.
3.Testing trained model:
Now,I am loading my model and finally testing it.
4.OUTPUT: