Change 'yolov4ObjectDetector' from read-only settings.
7 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Ayush Anand
2024-1-10
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!
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Recognition, Object Detection, and Semantic Segmentation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!