...
In a new tab, open up our Colab notebook: https://colab.research.google.com/drive/1HIzjqz5iboY2M1p4rfB2ktytr3-bf8dL?usp=sharing
Click ‘Copy to Drive’. This will copy the notebook to your Google Drive and open it in a new tab.
In your copy of the Colab, go to the ‘Runtime’ menu and select ‘Change runtime type’. Make sure a GPU option is selected such as 'T4 GPU'.
Finally, adjust the settings block. Here are what each variable in that block means:
RF_WORKSPACE - The ID of your Roboflow workspace. See image below for where to obtain this in your Roboflow account.
RF_PROJECT - The ID of your Roboflow project. See image below for where to obtain this in your Roboflow account.
RF_VERSION - The version of your Roboflow dataset. See image below for where to obtain this in your Roboflow account.
RF_API_KEY - Your Roboflow API Key. You guest it… see the image below for where to obtain this in your Roboflow account.
EXPORT_PATH - An optional location within your Google Drive where you can tell the script to save your trained model. There is an optional block at the end of the notebook that will connect to your Google drive. If you use this option, be sure to accept the permissions prompts and give full access to your Google Drive.
TRAINING_EPOCHS - This tells the script how long to train your model. To make a long story, short, there is an optimal amount of training for any given dataset. If you train the model too little, it’ll be wildly inaccurate. Train it too much and it will become ‘overfit' – meaning it will make its definitions of classes too rigid based on the dataset at hand and will also be inaccurate. Usually a larger dataset can be trained through more ‘epochs’ without overfitting. This is an area where experience and trial and error come in. If you have a reasonably large datasets (say about 300 annotated images with augmentations that make the dataset several thousand images in size) 100 epochs is a good place to start. A small model with only a handful of images might only need 10 or 20 epochs. Our notebook will output training graphs that show metrics related to the training process. One graph that is particularly important is the class loss graph which should look like a nice curve, starting high, dropping rapidly, and then leveling off with a tail that isn’t too long. This is an area where practice helps these concepts sink in. Eventually you’ll be able to compare the performance of a model with its graphs and have an intuitive understanding of what went wrong or right in the training process. Much has been written on this topic, so a quick search on Google or Youtube will go a long way in understanding the training process at a deeper level.
...
Run Through the Script
At this point, you should be all set to train your custom model! Simply step through one code block at a time pressing the little play button on the left and waiting for a checkbox to appear before moving on to the next block. Some blocks will take a significantly longer time to run. Be sure not to close the Colab or you will have to start at the top again (despite the checkboxes remaining).
Note |
---|
Note that when you get to the block labeled ‘mount Google Drive’, Colab will ask permission to access your Google Drive. You must grant full access to your drive in order for this script to work. Be sure to login when prompted to the correct Google account and grant all permissions. |
...
Finished!
When all of the code blocks have been run, you’ll have a model that can be used in computer vision deployments. If you established an ‘EXPORT_PATH' in the notebook settings, and you ran the last block of the notebook, you’ll have a file on your Google Drive called ‘best.pt’. This file can be uploaded to your Roboflow project or used in our Video Cluster Counting notebook.
Next Steps
...