the function of trainMaskRCNN repot an error

hellow, everyon
I want to make a maskrcnn net for my data,
first I use Image Labeler
Second ,I make a dataStore,reference supporting documents
[imdsRGB,pxds]=pixelLabelTrainingData(gTruth);
[~,blds] = objectDetectorTrainingData(gTruth);
imdsMask=imageDatastore("PixelLabelData_2\", ...
"ReadFcn",@denseMasks)
imdsMask.Files=pxds.Files;
trainSet=combine(imdsRGB,blds,imdsMask);
function data=denseMasks(imds)
pixelLabelIDs=[1 3 4];%get from gtruth
h=480;%rgbImagesize
w=640;%rgbImagesize
numarray=numel(pixelLabelIDs);
Masksarray=false(h,w,numarray);
a=zeros(h,w);
I=imread(imds);
for i=1:numarray
n=pixelLabelIDs(i);
a(:)=n;
m=a==I;
Masksarray(:,:,i)=m;
end
data=Masksarray;
end
I think the data set I built is correct
Then,I construct a network
classnames={'Wheel','shallowRut','deepRut'};
inputsize=[480,640,3];
anchorBoxes=estimateAnchorBoxes(blds,3)
network = maskrcnn("resnet50-coco",classnames,anchorBoxes,"InputSize",inputsize)
Then,I make trainoption and start to train
do_train_maskRCN=1;
if do_train_maskRCN
options = trainingOptions("adam", ...
InitialLearnRate=0.001, ...
LearnRateSchedule="piecewise", ...
LearnRateDropPeriod=1, ...
LearnRateDropFactor=0.95, ...
Plots="training-progress", ...
MaxEpochs=10, ...
MiniBatchSize=3, ...
BatchNormalizationStatistics="moving", ...
ResetInputNormalization=false, ...
ExecutionEnvironment="gpu", ...
VerboseFrequency=50);
trainedDetector = trainMaskRCNN(trainSet,network,options);
end
The error is at the last code
I have consulted all the relevant support documentation, I don't know what the problem is, is there a problem with my data set Settings ?

 Accepted Answer

Hi Yan,
I'm not a MaskRCNN expert and I don't use it frequently. But here are some of my observations:
From the documentation, the second column of the data is an MX4 matrix, where M is the number of objects. So in your case, I think M is 1, right? The fourth column is a HxWxM matrix where HxW is the height and width of the image and M is the number of objects. Therefore, the 4th column cell should hold a matrix with size 480x640x1.
See a dataset sample size in this example.

More Answers (0)

Asked:

on 16 Nov 2023

Answered:

on 17 Nov 2023

Community Treasure Hunt

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

Start Hunting!