Using custom weights and cfg file, is there a clear documentation in Matlab to use them for yolov3 object detection?
9 views (last 30 days)
Show older comments
The code below is working if we are using the pretrained model but not your own weights and cfg files.
% Load YOLOv3 model
yolov3 = yolov3ObjectDetector('darknet53-coco');
2 Comments
Cris LaPierre
on 19 Jan 2024
It is my understanding that, if you want to use custom weights, you will need to retrain the model. Can you say more about what you want to do? What type of data is in your cfg file?
Answers (1)
Aastha
on 25 Nov 2024 at 5:11
I understand that you want to use your custom weights and configuration files in a YOLOv3 model in MATLAB.
To get started, you first need to load the YOLOv3 model with the correct architecture. You may refer to the MATLAB code given below to do this:
% Load YOLOv3 model
name = 'darknet53-coco';
detector = yolov3ObjectDetector(name);
disp(detector);
The output of the above code will show properties of the “detector”:
yolov3ObjectDetector with properties:
Network: [1x1 dlnetwork]
AnchorBoxes: {2x1 cell}
ClassNames: [80x1 categorical]
InputSize: [416 416 3]
PredictedBoxType: 'axis-aligned'
ModelName: 'tiny-yolov3-coco'
In the above code snippet, the detector has a “Network” property of type “dlnetwork”. You can access this using the dot operator as illustrated in the MATLAB code snippet below:
Net = detector.Network;
To visualize the architecture, use the “plot” function as shown in the MATLAB code below:
plot(Net);
The “Net” variable contains a “layers” property, which holds all the weights and biases. You may refer to the code snippet below to access it:
Layers = Net.Layers;
You can then iterate through the layers to set the weights and biases based on the custom weights obtained from Google Colab training.
To modify the number of output classes, you can specify the arguments when creating the YOLOv3 detector object:
detector = yolov3ObjectDetector(name, classes, aboxes);
This command creates a pretrained YOLOv3 object detector and configures it using the specified set of object classes and anchor boxes.
For more information about the YOLOv3 model, you may refer to the following link of MathWorks documentation on YOLOv3 Object Detector:
I hope this helps!
0 Comments
See Also
Categories
Find more on Image Data Workflows in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!