Error while training SSD object detector

1 次查看(过去 30 天)
i am using MATLAB 2020a to train SSD object detetctor for my database.I receive error which i am unable to troubleshoot. please help me out.
here is the code:
vehicleDataset1=vehicleDataset1.wbc;
rng(0);
shuffledIndices1 = randperm(height(vehicleDataset1));
idx1 = floor(0.6 * length(shuffledIndices1) );
trainingData1 = vehicleDataset1(shuffledIndices1(1:idx1),:);
testData1 = vehicleDataset1(shuffledIndices1(idx1+1:end),:);
imdsTrain1 = imageDatastore(trainingData1{:,'filename'});
bldsTrain1 = boxLabelDatastore(trainingData1(:,'wbc'));
imdsTest1 = imageDatastore(testData1{:,'filename'});
bldsTest1 = boxLabelDatastore(testData1(:,'wbc'));
trainingData1 = combine(imdsTrain1,bldsTrain1);
testData1 = combine(imdsTest1, bldsTest1);
data1 = read(trainingData1);
I1 = data1{1};
bbox1 = data1{2};
annotatedImage1 = insertShape(I1,'Rectangle',bbox1);
annotatedImage1 = imresize(annotatedImage1,2);
figure
imshow(annotatedImage1)
inputSize1 = [300 300 3];
numClasses1 = width(vehicleDataset1)-1;
lgraph1 = ssdLayers(inputSize1, numClasses1, 'resnet50');
augmentedTrainingData1 = transform(trainingData1,@augmentData);
augmentedData1 = cell(4,1);
for k = 1:4
data1 = read(augmentedTrainingData1);
augmentedData1{k} = insertShape(data1{1},'Rectangle',data1{2});
reset(augmentedTrainingData1);
end
figure
montage(augmentedData1,'BorderSize',10)
preprocessedTrainingData1 = transform(augmentedTrainingData1,@(data)preprocessData(data,inputSize1));
data1 = read(preprocessedTrainingData1);
I1 = data1{1};
bbox1 = data1{2};
annotatedImage1 = insertShape(I1,'Rectangle',bbox1);
annotatedImage1 = imresize(annotatedImage1,2);
figure
imshow(annotatedImage1)
options = trainingOptions('sgdm',...
'InitialLearnRate',5e-5,...
'MiniBatchSize',16,...
'Verbose',true,...
'MaxEpochs',50,...
'Shuffle','every-epoch',...
'VerboseFrequency',10,...
'CheckpointPath',tempdir);
[detector1,info1] = trainSSDObjectDetector(preprocessedTrainingData1,lgraph1,options);
data1 = read(testData1);
I1 = data1{1,1};
I1 = imresize(I1,inputSize1(1:2));
[bboxes1,scores1] = detect(detector1,I1, 'Threshold', 0.4);
I1 = insertObjectAnnotation(I1,'rectangle',bboxes1,scores1);
figure
imshow(I1)
here is error:
Invalid transform function defined on datastore.
The cause of the error was:
Error using bboxwarp>iParseInputs (line 324)
The value of 'bboxA' is invalid. Expected input number 1, bboxA, to be integer-valued.
Error in bboxwarp (line 81)
params = iParseInputs(bboxA,tform,ref,varargin{:});
Error in augmentData (line 23)
[B{2},indices] = bboxwarp(A{2},tform,rout,'OverlapThreshold',0.25);
Error in matlab.io.datastore.TransformedDatastore/applyTransforms (line 489)
data = ds.Transforms{ii}(data);
Error in matlab.io.datastore.TransformedDatastore/read (line 162)
[data, info] = ds.applyTransforms(data, info);
Error in nnet.internal.cnn.DataLoader/manageReadQueue (line 161)
data = read(self.Datastore);
Error in nnet.internal.cnn.DataLoader/readAhead (line 192)
manageReadQueue(self);
Error in nnet.internal.cnn.DataLoader (line 80)
readAhead(self);
Error in nnet.internal.cnn.GeneralDatastoreDispatcher (line 272)
this.DataLoader = nnet.internal.cnn.DataLoader(ds,...
Error in nnet.internal.cnn.DataDispatcherFactory.createDataDispatcherMIMO (line 170)
nnet.internal.cnn.GeneralDatastoreDispatcher( ...
Error in vision.internal.cnn.trainNetwork>iCreateTrainingDataDispatcher (line 190)
dispatcher = nnet.internal.cnn.DataDispatcherFactory.createDataDispatcherMIMO( ...
Error in vision.internal.cnn.trainNetwork (line 40)
trainingDispatcher = iCreateTrainingDataDispatcher(ds, mapping, trainedNet,...
Error in trainSSDObjectDetector (line 233)
[network, info] = vision.internal.cnn.trainNetwork(...
Error in wbc_detetctor_traininga (line 61)
[detector1,info1] = trainSSDObjectDetector(preprocessedTrainingData1,lgraph1,options);

采纳的回答

Divya Gaddipati
Divya Gaddipati 2020-6-16
Make sure your groundtruths are valid and non-empty i.e., the values of the bounding boxes are finite, positive, non-fractional, non-NaN and should be within the image boundary with a positive height and width. You should either discard or fix the samples with invalid bounding boxes.
  2 个评论
Madura Meenakshi Ramamoorthi
Hi, Can you please tell how to discard invalid bounding boxes
Huma Hafeez
Huma Hafeez 2021-5-24
Thanks for your reply. You are right, there was a problem with ground truth

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile 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!

Translated by