Change 'yolov4ObjectDetector' from read-only settings.
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Rodrigo
am 10 Jan. 2024
Kommentiert: Rodrigo
am 11 Jan. 2024
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 Kommentare
Akzeptierte Antwort
Ayush Anand
am 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!
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Recognition, Object Detection, and Semantic Segmentation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!