Error when training Fast R-CNN network with roi input
Show older comments
When I begin to train a fast R-CNN network with the trainingData input datastore I receive an error
my network is:

I am only detecting one class, and all my ~6000 training images contain that class and I have marked it with a bounding box.
my code is:
clear
create_fast_RCNN_network_with_parameters_simpler_network;
load("ribeye_groundtruth_table.mat");
rng(1);
shuffledIndices = randperm(height(gTruth));
idx = floor(0.65 * height(gTruth));
trainingIdx = 1:idx;
trainingDataTbl = gTruth(shuffledIndices(trainingIdx),:);
validationIdx = idx+1 : idx + 1 + floor(0.25 * length(shuffledIndices) );
validationDataTbl = gTruth(shuffledIndices(validationIdx),:);
testIdx = validationIdx(end)+1 : length(shuffledIndices);
testDataTbl = gTruth(shuffledIndices(testIdx),:);
imdsTrain = imageDatastore(trainingDataTbl{:,'imageFilename'});
bldsTrain = boxLabelDatastore(trainingDataTbl(:,'RibEye'));
imdsValidation = imageDatastore(validationDataTbl{:,'imageFilename'});
bldsValidation = boxLabelDatastore(validationDataTbl(:,'RibEye'));
imdsTest = imageDatastore(testDataTbl{:,'imageFilename'});
bldsTest = boxLabelDatastore(testDataTbl(:,'RibEye'));
miniBatchSize = 14;
trainingData = combine(imdsTrain,bldsTrain);
validationData = combine(imdsValidation,bldsValidation);
testData = combine(imdsTest,bldsTest);
%this shows the first training data correctly!
data = read(trainingData);
I = data{1};
bbox = data{2};
annotatedImage = insertShape(I,'rectangle',bbox);
annotatedImage = imresize(annotatedImage,2);
figure
imshow(annotatedImage)
options = trainingOptions('sgdm',...
'MaxEpochs',10,...
'Momentum',0.9,...
'MiniBatchSize', miniBatchSize,...
'InitialLearnRate',1e-3,...
'LearnRateDropFactor', 0.1, ...
'LearnRateDropPeriod', 2, ...
'L2Regularization', 1e-5, ...
'CheckpointPath',tempdir,...
'ValidationData',validationData,...
'Shuffle','every-epoch', ...
'ValidationFrequency',220, ...
'Plots', 'training-progress');
[trainedDetector, info] = trainFastRCNNObjectDetector(trainingData, lgraph, options);
% after extracting region proposals from training datastore I receve the below error output:
testing trainingData with read yields:
data = read(trainingData)
data =
1×3 cell array
{576×720×3 uint8} {[73 43 486 277]} {[RibEye]}
Which seems correct.
I have also tested it with readall and I can see no problems.
but straight after training starts I receive this error:
*******************************************************************
Training a Fast R-CNN Object Detector for the following object classes:
* RibEye
--> Extracting region proposals from training datastore...done.
Input datastore returned more than one observation per row for network input 2.
Error in nnet.internal.cnn.dispatcher.GeneralDatastoreDispatcher>iAssertDataContainsOneObservationPerRow (line 631)
iAssertExpectedMiniBatchSize(i, numObservations, expectedBatchSize);
Error in nnet.internal.cnn.dispatcher.GeneralDatastoreDispatcher>iGetDataResponseSizesForMISO (line 540)
iAssertDataContainsOneObservationPerRow(i, numObservations, inputSize);
[this.DataSize, this.ResponseSize] = iGetDataResponseSizesForMISO(exampleData, ...
nnet.internal.cnn.dispatcher.GeneralDatastoreDispatcher( ...
dispatcher = nnet.internal.cnn.dispatcher.DispatcherFactory.createDispatcherMIMO( ...
trainingDispatcher = iCreateTrainingDataDispatcher(ds, mapping, trainedNet,...
[network, info] = vision.internal.cnn.trainNetwork(...
[detector, ~, info] = fastRCNNObjectDetector.train(trainingData, lgraph, options, executionSettings, params, checkpointSaver);
What could be causing this error?
I was able to train this network with a minibatchsize of 8. However after I modified some of my convolutional layers it no longer works with minibatchsize of 8.
Accepted Answer
More Answers (0)
Categories
Find more on Object Detection in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!