Change 'yolov4ObjectDetector' from read-only settings.
7 views (last 30 days)
Show older comments
Hey.
I am trying to use the yolov4ObjectDetector to complement my Network but I am struggling with one error regarding the name of the ouput layer. However, when I try to replace the layer with an equivalent layer but with the appropriate name I receive the following error:
Unable to set the 'Network' property of class 'yolov4ObjectDetector' because it is read-only.
Error in main (line 57)
detector.Network = replaceLayer(detector.Network,'customOutputConv1',newoutput);
Do you know if it is possible to change this read-only settings?
0 Comments
Accepted Answer
Ayush Anand
on 10 Jan 2024
Hi Rodrigo,
In MATLAB, the "Network" property of the "yolov4ObjectDetector" is read-only, which means you cannot directly modify it after the object is created. This is to ensure the integrity of the pre-trained networks and their associated properties.
If you want to modify the network architecture, such as replacing a layer with a different one, you should do this before creating the "yolov4ObjectDetector" object. You would typically modify the layers of the deep learning network and then create the object detector with the modified network.
Here's a general approach on how you could do the same:
% Load the pre-trained YOLOv4 network
net = load('yolov4Network.mat'); % Replace with your network source
lgraph = layerGraph(net);
% Replace the layer with the new layer with the correct name
newLayer = convolution2dLayer([1, 1], numFilters, 'Name', 'newOutputLayerName', 'WeightLearnRateFactor',1, 'BiasLearnRateFactor',1);
lgraph = replaceLayer(lgraph, 'customOutputConv1', newLayer);
% Create the yolov4ObjectDetector with the modified network
detector = yolov4ObjectDetector(lgraph, anchorBoxes, classNames);`
You can refer to the following link to read more on the "replaceLayer" function:
I hope this helps!
More Answers (0)
See Also
Categories
Find more on Recognition, Object Detection, and Semantic Segmentation 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!