instance segmentation based on polygon labeling?

6 visualizaciones (últimos 30 días)
Minwuye Mesfin Woldeamanuel
Minwuye Mesfin Woldeamanuel el 19 de Sept. de 2023
Comentada: Joss Knight el 25 de Sept. de 2023
i am trying to train a mocel for instance segementation using mask Rcnn and i have labelled 1128 image using imqage labeller polygon labelling.
% % Load the ground truth labels using gTruth
load gTruth_1128.mat; % Load your gTruth data
data = gTruth;
classnames = gTruth.LabelDefinitions.Name
% Define the directory where your bounding box data is located and RGB
% image located
RGBDir = 'I:\PROJECTS\PhD Year 2\comparision of Image segmentation models\Data1\Dataset_2';
maskDir = 'I:\PROJECTS\PhD Year 2\comparision of Image segmentation models\Data1\Training\dataset'; % Replace with the directory where you want to save the files
numClasses = 4; % Number of classes
% load the groudtruth
A = 'traning_data.mat';
loadedData = load(A);
% Access the cell array data from the loaded data
cellArrayData = loadedData.combinedCellArray;% Replace 'yourVariableName' with the correct variable name
cellArrayData =cell2table(cellArrayData);
% % % Create a Image source for the dataset
imds = imageDatastore(RGBDir);
% Create a boxLabelDatastore
blds = boxLabelDatastore(cellArrayData(:,(2:3)));
% Create a custom ReadFcn for the maskimageDatastore
readFcn = @(filename) customReadFcn(filename);
% Create the imageDatastore with the custom ReadFcn
imds_mask = imageDatastore(maskDir, 'FileExtensions', {'.mat'}, 'ReadFcn', readFcn);
ds = combine(imds,blds);
ds = combine(ds,imds_mask);
preview(ds)
net = maskrcnn("resnet50-coco",classnames,InputSize=imageSize)
options = trainingOptions("sgdm", ...
InitialLearnRate=0.001, ...
LearnRateSchedule="piecewise", ...
LearnRateDropPeriod=1, ...
LearnRateDropFactor=0.95, ...
Plot="none", ...
Momentum=0.9, ...
MaxEpochs=10, ...
MiniBatchSize=20, ...
BatchNormalizationStatistics="moving", ...
ResetInputNormalization=false, ...
ExecutionEnvironment="gpu", ...
VerboseFrequency=50);
% TT = trainMaskRCNN(ds,net,options);
doTraining = true;
if doTraining
[net,info] = trainMaskRCNN(ds,net,options,FreezeSubNetwork="backbone");
modelDateTime = string(datetime("now",Format="yyyy-MM-dd-HH-mm-ss"));
save("trainedMaskRCNN-"+modelDateTime+".mat","net");
end
But i am iaving this error
Error using minibatchqueue
Invalid transform function defined on datastore.
mbqTrain = minibatchqueue(preprocessDS,4, ...
Caused by:
Index in position 3 exceeds array bounds. Index must not exceed 3.
can you help???
  1 comentario
Joss Knight
Joss Knight el 25 de Sept. de 2023
I'm not sure, it's possible there's a bug in your custom ReadFcn. Can you put a breakpoint in it and see if it's erroring?

Iniciar sesión para comentar.

Respuestas (0)

Productos


Versión

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by