Training Models using Supervisely
Machine Learning, Artificial Intelligence, and Deep Learning are some of the most complex, yet highly demanded fields of expertise today. There are innumerable resources and tools to work in these fields, and one such popular tool is Supervisely.
Supervisely is a web platform where we can build Deep Learning solutions. It is a service meant for dataset management, annotation, and preparation for Deep Learning. Supervisely is used by students, researchers, and businessmen to manage large-scale datasets and even preserve privacy by working with Supervisely on their servers.
In this article, we will be looking at how to train models using Transfer Learning in Supervisely. To work with Supervisely, we first need to create an account. For non-commercial purposes, the account is created for free.
When the account is first created, we are logged in as the admin user. There is a default workspace that is created. We can continue with this workspace or create our own. A sample of a custom workspace is shown below with the name MLOps_Task 6.
Inside the new workspace, we can start a new project by importing the required dataset.
The dataset can be imported by a simple drag-and-drop operation from the local system onto the given space.
The dataset being used has been taken from Kaggle and it is a dataset that is used to design models to predict brain tumors from the MRI images. The link to the dataset is given in the References section. The data used is only of all the images where a brain tumor is found.
Once the images have been uploaded, the important parts (tumors) must be highlighted, which is also called an annotation. The annotation must be done for each image so that the existing dataset can be expanded further for model training. An example of an annotated image is given below. The large black-lined red-filled dots are the points manually placed to mark the regions of the tumor’s existence.
Once all the images have been annotated, we expand the dataset for training the model. In our attempt to train the model, we will be working with Instance Segmentation offered by Mask R-CNN.
Once the instance segmentation is completed, we see a new project added to the workspace.
Now, we finally proceed with the creation of the train/validation set, by running a DTL script once again, which results in the creation of the third project in the workspace.
With the final project, we can train our model. In Supervisely, we can train neural networks from scratch or implement transfer learning. But in both cases, the computer system being used to train the model has specific requirements it must fulfill as seen in the image below.
To use an existing NN model, we can import pre-trained models from the Neural Networks section. Once the model is cloned, we can train the model by choosing the desired dataset (project).
The addition of agents is done in the Clusters section, where detailed instructions are given as shown in Figure 9 to add the agent for training. A suitable agent can be found by launching an EC2 instance provided by AWS. By creating an account in AWS, we can use a suitable AMI (which works much like a container image in Docker Hub) to train the NN model. However, the AMIs with GPUs are not provided free of charge. I used the Deep Learning AMI (Amazon Linux 2) Version 30.0, with p2.xlarge flavor.
Once the EC2 instance has been launched, we can log in to the instance using the SSH and execute the command mentioned in the Clusters section of Supervisely on the command line of the instance. Once the agent has been successfully added, we can train the model we have imported using Transfer Learning.
To observe the progress of the training, we can use the tasks bar. It provides charts to observe the loss while training the model, logs of the model being trained, etc.
We can also see the checkpoints based on the number of epochs for which the model has been trained in the Tasks section.
Once the model has been trained, we can either test it using the same agent or even download the trained weights as a .zip file. The downloaded model weights are in the .h5 file format.
This work has been done as a part of the MLOps Training program conducted by Mr. Vimal Daga from LinuxWorld Informatics Pvt. Ltd.
Check out more of my work in this program below!
- Working with Jenkins — An Introduction: https://medium.com/@akshayavb99/working-with-jenkins-an-introduction-48ecf3de3c25
- Working with Jenkins, Docker, Git, and GitHub — Part II: https://medium.com/@akshayavb99/working-with-jenkins-docker-git-and-github-part-ii-d74b6e47140c
- An Introduction to Transfer Learning: https://medium.com/@akshayavb99/an-introduction-to-transfer-learning-6b54696fb405
- Integrating ML/DL with DevOps: https://medium.com/@akshayavb99/integrating-ml-dl-with-devops-258dde42e220