Hi Tewodros,
I understand you have a custom dataset and you want to train a YOLO Detector. To train a YOLO v4 object detection network on a labeled data set, use the "trainYOLOv4ObjectDetector" function.
Firstly you must specify the class names for the data set you intend to use to train the network. Then, train an untrained or pretrained network by using the "trainYOLOv4ObjectDetector" function. The training function returns the trained network as a "yolov4ObjectDetector" object.
You can refer to this crisp example for the same: https://www.mathworks.com/help/vision/ref/trainyolov4objectdetector.html or you can also open the example in your MATLAB Desktop using:
openExample('vision/TrainYOLOV4NetworkForVehicleDetectionExample')
Make sure you have the following installations beforehand:
- MATLAB® R2022a or later
- Deep Learning Toolbox
- Computer Vision Toolbox
The training process in the example mostly consists of 3 main parts:
1- Prepare Training Data:
- Prepare data which can be loaded as a table with the first column containing the training images filepath and the second column containing the labeled bounding boxes coordinates.
- Also specify the input size to use for resizing the training images
2- Estimate Anchor Boxes:
- Estimate the "estimateAnchorBoxes" function to estimate anchor boxes.
- The parameter of "numAnchors" is set to 6 in the example.
- You can refer to https://www.mathworks.com/help/vision/ug/estimate-anchor-boxes-from-training-data.html for choosing anchor box parameter value.
3- Configure and Train Yolov4 network:
- Specify the class names.
- Configure the pretrained YOLO v4 deep learning network to be retrained for the new dataset by using "yolov4ObjectDetector" function.In the example it has used "tiny-yolov4-coco" as the pretrained model.
- Finally specify the training options and retrain the pretrained YOLO v4 network on the new dataset.
All these main steps enumerated are followed in detail in the example mentioned above.For an in depth view of object detection using Yolov4 Deep Learning(including data augmentation, evaluation, etc) refer to : https://www.mathworks.com/help/vision/ug/object-detection-using-yolov4-deep-learning.html
Hope this helps.