Error, Detector in YOLO V4

16 views (last 30 days)
weam
weam on 4 Mar 2023
Commented: Walter Roberson on 12 Mar 2023
Hello everyone, can you help me? I am using the example "Object Detection Using YOLO v4 Deep Learning" in the document Matlab help, but with a change in the dataset (customs data). when I reach to detector appear the error.
this code :-
detector = yolov4ObjectDetector("csp-darknet53-coco",className1,className2,anchorBoxes,InputSize=inputSize);
this error appear:-
Error using yolov4ObjectDetector/parsePretrainedDetectorInputs
Expected a string scalar or character vector for the parameter name.
Error in yolov4ObjectDetector (line 218)
params = yolov4ObjectDetector.parsePretrainedDetectorInputs(varargin{:});
Error in recognitionThree (line 113)
detector = yolov4ObjectDetector("csp-darknet53-coco",className1,className2,anchorBoxes,InputSize=inputSize);

Answers (2)

Walter Roberson
Walter Roberson on 6 Mar 2023
detector = yolov4ObjectDetector("csp-darknet53-coco",className1,className2,anchorBoxes,InputSize=inputSize);
So in your call, the name parameter is being passed as "csp-darknet53-coco" . The classes parameter is being passed as className1 . The aboxes parameter is being passed as className2 . Then you get to the anchorBoxes parameter in your call, and since the positional parameter locations have been filled, the code has to match the contents of anchorBoxes to one of the option names. But your anchorBoxes variable is not a character vector or a string array, so you get an error message.
The classes has to be passed as a single parameter, such as {className1, className2}
  7 Comments
weam
weam on 12 Mar 2023
Edited: weam on 12 Mar 2023
function data = augmentData(A);
data = cell(size(A)); for ii = 1:size(A,1) I = A{ii,1}; bboxes = A{ii,2}; labels = A{ii,3}; sz = size(I);
if numel(sz) == 3 && sz(3) == 3
I = jitterColorHSV(I,...
contrast=0.0,...
Hue=0.1,...
Saturation=0.2,...
Brightness=0.2);
end
% Randomly flip image.
tform = randomAffine2d(XReflection=true,Scale=[1 1.1]);
rout = affineOutputView(sz,tform,BoundsStyle="centerOutput");
I = imwarp(I,tform,OutputView=rout);
% Apply same transform to boxes.
[bboxes,indices] = bboxwarp(bboxes,tform,rout,OverlapThreshold=0.25);
labels = labels(indices);
% Return original data only when all boxes are removed by warping.
if isempty(indices)
data(ii,:) = A(ii,:);
else
data(ii,:) = {I,bboxes,labels};
end
end
end
Walter Roberson
Walter Roberson on 12 Mar 2023
the error message says
Error in recognitionThree>augmentData (line 231)
bboxes = A{ii,{1,1}};
but that line does not exist in the augmentData function that you posted.

Sign in to comment.


Pritesh Shah
Pritesh Shah on 5 Mar 2023
Check input command of this function.

Community Treasure Hunt

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

Start Hunting!