Yolov4 code problem

9 visualizzazioni (ultimi 30 giorni)
sungho
sungho il 31 Ago 2024
Commentato: sungho il 4 Set 2024
hi guys, i need to help to fix my code error.
to train yolov4 model for my dataset. i put right input size and everything. but happend error again and again.
error code is like this
Error using reshape
Number of elements must not change. Use [] as one of the size inputs to automatically calculate the appropriate size for that dimension.
Error in trainYOLOv4ObjectDetector>iGetMaxIOUPredictedWithGroundTruth (line 425)
iou(:,:,:,batchSize) = reshape(maxOverlap,h,w,c);
Error in trainYOLOv4ObjectDetector>iGenerateTargets (line 319)
iou = iGetMaxIOUPredictedWithGroundTruth(bx,by,bw,bh,groundTruth);
Error in trainYOLOv4ObjectDetector>calculateLoss (line 234)
[boxTarget, objectnessTarget, classTarget, objectMaskTarget, boxErrorScale] = iGenerateTargets(gatheredPredictions, YTrain, params.InputSize, params.AnchorBoxes, penaltyThreshold);
Error in trainYOLOv4ObjectDetector>@(varargin)calculateLoss(lossParams,varargin) (line 167)
lossFcn = @(varargin) calculateLoss(lossParams,varargin);
Error in images.dltrain.internal.SerialTrainer>modelGradients (line 139)
loss = lossFcn(networkOutputs{:},targets{:});
Error in deep.internal.dlfeval (line 17)
[varargout{1:nargout}] = fun(x{:});
Error in deep.internal.dlfevalWithNestingCheck (line 15)
[varargout{1:nargout}] = deep.internal.dlfeval(fun,varargin{:});
Error in dlfeval (line 31)
[varargout{1:nargout}] = deep.internal.dlfevalWithNestingCheck(fun,varargin{:});
Error in images.dltrain.internal.SerialTrainer/fit (line 76)
[loss,grad,state,networkOutputs,lossData] = dlfeval(@modelGradients,self.Network,self.LossFcn,...
Error in images.dltrain.internal.dltrain (line 102)
net = fit(networkTrainer);
Error in trainYOLOv4ObjectDetector (line 183)
[trainedDetector,infoTrain] = images.dltrain.internal.dltrain(mbq,detector,options,lossFcn,metrics,validationPatienceMetric,'ExperimentMonitor',params.ExperimentMonitor);

Risposte (1)

Shubham
Shubham il 31 Ago 2024
Hey Sungho,
It appears that you’re encountering an issue with the ’reshape’ function in your YOLOv4 model. The error message being encountered during the training of a YOLOv4 object detector in MATLAB suggests an issue with the reshaping of arrays within the function ‘iGetMaxIOUPredictedWithGroundTruth’. This error often arises due to a mismatch in expected dimensions during operations like reshaping or concatenation.
I believe you can refer to the following MATLAB Answer which discusses the similar issue with the same stack trace here: https://www.mathworks.com/matlabcentral/answers/2146179-how-i-can-fix-internal-change-in-number-of-elements-in-yolo-v4-network-while-training
I hope this would resolve the issue!
  5 Commenti
Shubham
Shubham il 4 Set 2024
Modificato: Shubham il 4 Set 2024
Use the paperclip icon in the 'INSERT' section to attach any relevant files.
Also what are you doing different for the three training folders? I don't think this would be a sporadic error. Also if you are able to run it over one of the folder, then has it resolved the issue you are facing?
sungho
sungho il 4 Set 2024
i found problem. if i train bbox = xmin, ymin, bboxWidth, bboxHeight then, reshape error code happend. and i try with bbox = centerX, centerY, bboxWidth, bboxHeight then training was successful without error. can you advise about it?

Accedi per commentare.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by