Face Recognition using Transfer Learning and using VGG16

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.
No alt text provided for this image
  • 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.
No alt text provided for this image

Architecture of VGG16 :

No alt text provided for this image

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.

No alt text provided for this image

Also,used keras_preprocessing module to generate images from ImageDataGenerator() function which are coloured images .

No alt text provided for this image

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.
No alt text provided for this image
  • Now, will add new layers in order to achive fine tuning.
No alt text provided for this image
  • Now we have to connect new layers (fine tuning) to the layers of vgg16 model.
No alt text provided for this image
No alt text provided for this image
  • 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.
No alt text provided for this image
  • At last we have to train our model using concept of transfer learning.
No alt text provided for this image

3.Testing trained model:

Now,I am loading my model and finally testing it.

No alt text provided for this image
No alt text provided for this image

4.OUTPUT:

No alt text provided for this image


No alt text provided for this image









要查看或添加评论,请登录

Shivam Agarwal的更多文章

社区洞察

其他会员也浏览了