Damaged Road Detection: Mask R-CNN on Supervisely
Sunil Maharana
Senior Data Engineer | GenAI, Databricks/Snowflake+DBT, ApacheSpark, Python, SQL
In this project, we are going to create our own model using transfer learning from the existing Mask R-CNN model to detect the damages on roads.
Supervisely is the leading platform for the entire computer vision lifecycle: from image annotation to building custom neural networks. It is a web platform where you can find everything you need to build Deep Learning solutions within a single environment.
Mask R-CNN
Mask Regional Convolutional Neural Network (R-CNN) is an extension of the Faster R-CNN object detection algorithm that adds extra features such as for instance segmentation and an extra mask head. This allows us to form segments on the pixel level of each object and also separate each object from its background.
The framework of Mask R-CNN is based on two stages:
- First, it scans the image to generate proposals; which are areas with a high likelihood to contain an object.
- Second, it classifies these proposals and creates bounding boxes and masks.
Let's begin Creating our model using Transfer Learning to identify damaged roads.
1. Create an account on Supervisely and login to your account:
2. Create a workspace that will contain your projects:
Your workspace is created.
3. Now we have to upload the images of damaged roads which I collected from internet,
4. Now we have to do image segmentation to segment the part of a road that is damaged which is very easy to do with Supervisely, it annotates automatically.
5. Now we require a large dataset for training our model so run DTL for image augmentation to create train and Val dataset.
6. It automatically gives the code that we require to do augmentation (we can change the multiply value to increase the size of the dataset).
7. So now we are ready with the input dataset to be given to the neural network for model training.
8. We are using a pre-created model and doing transfer learning, so adding a Neural Network, I used the coco model and cloned it to my workspace.
9. Now we have a neural network and want to train the model.
>> When we go for train, it asks for agent. Now for trainig and testing our model we need to provide our own resources as supervisely doesn't provide it. So we have to attach an agent which can be our own machine or any cloud instance. Supervisely Agent is a simple open-source task manager available as a Docker image.
>> The Agent runs on a worker node. It connects to the Supervisely WEB instance and listens for the tasks (like neural net training request) to run. It handles downloading and uploading data to the web instance, sets up proper environments for the specific tasks to run, and keeps track of progress, successes and failures of individual tasks
10. Add an agent on the cluster page, it will give the instructions to follow.
11. The agent we provide should meet the requirements given (it should have GPU). So here I am using aws instance satisfying the requirements, using a deep learning image.
12. Select a GPU instance ( you may require to request for quota increase from aws support otherwise you won't be able to use it )
So, our instance is now ready.
Our agent is running, now we can train our Mask R-CNN model,
13. Go to Neural Networks and click on train, select the input project (our dataset)
The task will start now,
As we can see, model training and epochs have started.
Finally model is Trained Successfully!
We can check the logs,
This is workflow of the trained model,
We can see one more NN is added here, which is our trained neural network. Now we are testing our model,
14. Creating Best Training model for testing.
15. Adding other road images as input to it,
Model testing will start and we will get the testing result soon,
This is the complete workflow,
Finally we have tested our mask R-CNN model and it is working successfully as shown in the image,
So, this was how we can create our own Mask R-CNN model on Supervisely.