Transfer Learning
Tanuj Mathur
Digital Specialist Engineer at Infosys | RHCSA | DevOps | Amazon Web Services |
Humans are known to be the most intelligent and powerful creatures on this planet. They have the control over everything be it development or technology. Humans have been working with technology very closely and have developed techniques, which works exactly like the human mind. The reason being the smartness of the human brain and its high capability to recognise images or things and make predictions based on past experiences or calculations.
The human brain is so powerful that the experience and knowledge for a particular event can be reused for recognising some new set of objects or making new predictions, not much of exhaustive new training is required. The brain has the power to perceive everything very quickly and efficiently that the training needs not to be done from very zero for every new task that comes up. It has the capability of transferring the knowledge gained from one task to resolve the problems being faced in some completely different task using similar kind of knowledge.
Transfer Learning is a subset of Deep Learning in which the knowledge from the previous task can be further used to predict the results for a new task. The traditional models very completely isolated and the knowledge gained through them was restricted only to the models they were meant for but due to limitations of dataset and resources, some well-defined pre-trained models can be easily used by other users for predicting results of their models without any barriers.
MobileNet-V2 is one such architecture, which consists of a number of convolutional and pooling layers followed by a dense neural network and flattening layer, trained over a very large dataset and is capable enough to yield excellent results. All you need is to import the model, freeze the layers of the model, add a few dense layers, train the newly added layers, change hyperparameters and fetch the best results and you are ready to predict excellent results making use of a well-defined DeepNet network without any extra cost of resources and time.
Here, I have made a face-recognition system using the MobileNet Architecture for my family members with a very small dataset of 1200 images and added 3 new layers to the model, to be trained and fetched the results.
- The very first job was to click pictures of every member, which was accomplished using CV2 library of the OpenCV module of Python for the dataset comprising of training as well as testing data.
2. The second part was to use the pre-trained model MobileNet, add layers to it after freezing all the layers of the model and add new layers and a dataset of our own to predict the results if the face is of the person specified or not. The use of transfer learning enabled to make use of a smaller dataset and there was no requirement of high power resources and time to get better results.
Once the entire training code runs successfully, the model is ready to be saved and loaded to test and predict the faces.
And here is the output of the code.
GitHub repo link: https://github.com/tanuj5/transfer-learning.git
Happy Learning!