Using MobileNet to make a Celeb-Recognition Classifier with Transfer Learning

Using MobileNet to make a Celeb-Recognition Classifier with Transfer Learning

Brief about Transfer Learning: Transfer Learning is a technique in which we use a model that is pre-trained on a very large dataset, and by the weights of that model can be used in some other problem so that we can save us time and extensive computational power for some another task.

Transfer Learning Explained

Here’s how it works: First, you delete what’s known as the “loss output” layer, which is the final layer used to make predictions, and replace it with a new loss output layer for some particular prediction. This loss output layer is a fine-tuning node for determining how training penalizes deviations from the labeled data and the predicted output.

Next, you would take your smaller dataset and train it on the entire 50-layer neural network or the last few layers or just the loss layer alone. By applying these transfer learning techniques, your output on the new CNN will be identification based on your particular dataset.

Some of the famous pre-trained models present are ResNet50, VGG16, VGG19, MobileNet, inception V3, etc.

The overall architecture of the Mobilenet is as follows, having 30 layers with

  1. convolutional layer with stride 2
  2. depthwise layer
  3. pointwise layer that doubles the number of channels
  4. depthwise layer with stride 2
  5. pointwise layer that doubles the number of channels

etc.

No alt text provided for this image

First Step: First Step is to Load the MobileNet Model and Freeze all layers except the top 4, as we'll only be training the top 4.

NOTE: Here Freezing means we will not be using these layers as we don't want to train all the layers again that's the whole and sole purpose of transfer learning.

No alt text provided for this image

Second Step: We'll make a function that returns our FC Head and then we will add our FC Head back onto MobileNet

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

Third Step: Third Step is to Load our Celeb-Recognition Dataset to get the Details about the Dataset like total number of Images and Classes in both Tran and Validation.

Fourth Step: Fourth Step is to Train our model, I am using five epochs and 16 Batch Size here.

No alt text provided for this image

Here I am getting around 80% accuracy which is pretty good considering I've given only 150 images to train with only 5 epochs.

Final Step: Final Step is to load our classifier and test some images

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

Github Link for Code: https://github.com/Pulkit-debug/MLOps_Projects_Data/tree/master/MLOps_Project_4

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

Pulkit Verma的更多文章

社区洞察

其他会员也浏览了