Yolov4 code problem

조회 수: 8 (최근 30일)
sungho
sungho 2024년 8월 31일
댓글: sungho 2024년 9월 4일
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);

답변 (1개)

Shubham
Shubham 2024년 8월 31일
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
Shubham
Shubham 2024년 9월 4일
편집: Shubham 2024년 9월 4일
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 2024년 9월 4일
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?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Classification Trees에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by