Error while training SSD object detector
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Huma Hafeez
il 14 Giu 2020
Commentato: Huma Hafeez
il 24 Mag 2021
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);
0 Commenti
Risposta accettata
Divya Gaddipati
il 16 Giu 2020
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 Commenti
Madura Meenakshi Ramamoorthi
il 30 Gen 2021
Hi, Can you please tell how to discard invalid bounding boxes
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Recognition, Object Detection, and Semantic Segmentation in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!