Training Custom Object Detection Models using YOLO v4
Bird recognition and categorisation
Using YOLO V4
All source files, configuration files and image files (Birds) can be downloaded from my GitHub repository here.
https://github.com/rajeshvalluri/YOLOV4_Train/tree/main
Alexy’s Original GitHub repository here.
https://github.com/AlexeyAB/darknet
https://pjreddie.com/darknet/yolo/ Alexy’s homepage.
If you are completely new to YOLO, or running YOLO on Colab I suggest you check out my earlier video on how to run the pretrained YOLO model. This will help you understand the concepts first. It will help you setting up YOLO, uploading test images to Colab, testing them out get a grasp on what YOLO can and can not do.
This is part 2 of a two part series. Watch the first video to get started on the process.
Training on Colab
Once you have successfully finished labelling all your images, the next step is the fun step. This is when we fire up our YOLO model on Colab, and start training. The training process is extensive, and takes a really long time.
Session timeout prevention
By the way, the free version of Colab has some timeout limitations which will limit the amount of time you can train the model for. To work around this, you need to trick Colab into thinking that you are clicking it at regular intervals. To this end, we rely on a little JavaScript nugget. Open developer tools on the browser tab connected to Colab, and in “console” paste the following code.
The following Colab notebook will guide us through the rest of the video.
Prerequisites
Before we can start the training process, lets recap and see if we have all the required steps finished.
1) Image files and their corresponding YOLO specific label files ( with bounding box information)
2) obj.names file containing the names of classes (one class per row)
3) obj.data file (containing information about location of various files)
Once these prerequisites are met, we can start the training process. The following sequence of steps should be performed in the order given below.
You can get my Jupyter notebook from GitHub to get started with these steps.
https://github.com/rajeshvalluri/YOLOV4_Train/blob/main/YOLOv4_Training.ipynb
Connect to Colab
Open Google’s Colab and initiate a new session with GPU enabled.
Darknet Installation and Compilation
Clone the GitHub repository for YOLO V4, edit the build directives to use GPU and openCV and compile the darknet application
Download Pre-Trained Weights
From Alexy’s Google drive (Link shared by Alexy)
Google Drive
Upload the training images you have prepared to Colab
Upload the obj.names, obj.data and obj.classes files to Colab.
Train Model
Start training
Test and Validate
Test the trained model
source