Effacer les filtres
Effacer les filtres

Error in using trainPoint​PillarsObj​ectDetecto​r

2 vues (au cours des 30 derniers jours)
gaurav
gaurav le 27 Fév 2024
% Loading the pcd files from the specified location
path = fullfile("C:\Users\asus\Desktop\main",'Lidar');
lidarData = fileDatastore(path,'ReadFcn',@(x) pcread(x));
% Loading the 3-D bounding box labels
gtPath = fullfile("C:\Users\asus\Desktop\main",'Cuboids','labelinfo.mat');
data = load(gtPath,'gTruth');
Labels = timetable2table(gTruth.LabelData);
boxLabels = Labels(:,2:3);
% Displaying the full point cloud view
figure
ptCld = read(lidarData);
ax = pcshow(ptCld.Location);
set(ax,'XLim',[-50 50],'YLim',[-40 40]);
zoom(ax,2.5);
axis off;
reset(lidarData);
% Seleting region of interest
xMin = -11.04; % Minimum value along X-axis.
yMin = -10.0; % Minimum value along Y-axis.
zMin = -3.0; % Minimum value along Z-axis.
xMax = 11.04; % Maximum value along X-axis.
yMax = 30.0; % Maximum value along Y-axis.
zMax = 5.0; % Maximum value along Z-axis.
xStep = 0.16; % Resolution along X-axis.
yStep = 0.16; % Resolution along Y-axis.
dsFactor = 2.0; % Downsampling factor.
% Calculate the dimensions for the pseudo-image.
Xn = round(((xMax - xMin)/xStep));
Yn = round(((yMax - yMin)/yStep));
% Define point cloud parameters.
pointCloudRange = [xMin xMax yMin yMax zMin zMax];
voxelSize = [xStep yStep];
[croppedPointCloudObj,processedLabels] = cropFrontViewFromLidarData(...
lidarData,boxLabels,pointCloudRange);
% Display the cropped point cloud and the ground truth box labels
pc = croppedPointCloudObj{1,1};
gtLabelsother = processedLabels.other{1};
gtLabelsPedestrian = processedLabels.Pedestrian{1};
helperDisplay3DBoxesOverlaidPointCloud(pc.Location,gtLabelsother,...
'green',gtLabelsPedestrian,'magenta','Cropped Point Cloud');
reset(lidarData);
% Spliting the dataset into training and test data
rng(1);
shuffledIndices = randperm(size(processedLabels,1));
idx = floor(0.8 * length(shuffledIndices));
trainData = croppedPointCloudObj(shuffledIndices(1:idx),:);
testData = croppedPointCloudObj(shuffledIndices(idx+1:end),:);
trainLabels = processedLabels(shuffledIndices(1:idx),:);
testLabels = processedLabels(shuffledIndices(idx+1:end),:);
% Saving the training data in PCD format
writeFiles = true;
dataLocation = fullfile("C:\Users\asus\Desktop\main",'InputData');
[trainData,trainLabels] = saveptCldToPCD(trainData,trainLabels,...
dataLocation,writeFiles);
% Create a file datastore using fileDatastore to load PCD files using the pcread function.
lds = fileDatastore(dataLocation,'ReadFcn',@(x) pcread(x));
% Createa box label datastore using boxLabelDatastore for loading the 3-D bounding box labels.
bds = boxLabelDatastore(trainLabels);
% Use the combine function to combine the point clouds and 3-D bounding box labels into a single datastore for training.
cds = combine(lds,bds); % Define the number of prominent pillars.
P = 12000;
% Define the number of points per pillar.
N = 100;
anchorBoxes = calculateAnchorsPointPillars(trainLabels);
classNames = trainLabels.Properties.VariableNames;
detector = pointPillarsObjectDetector(pointCloudRange,classNames,anchorBoxes,...
'VoxelSize',voxelSize,'NumPillars',P,'NumPointsPerPillar',N);
executionEnvironment = "auto";
if canUseParallelPool
dispatchInBackground = true;
else
dispatchInBackground = false;
end
options = trainingOptions('adam',...
'Plots',"none",...
'MaxEpochs',60,...
'MiniBatchSize',3,...
'GradientDecayFactor',0.9,...
'SquaredGradientDecayFactor',0.999,...
'LearnRateSchedule',"piecewise",...
'InitialLearnRate',0.0002,...
'LearnRateDropPeriod',15,...
'LearnRateDropFactor',0.8,...
'ExecutionEnvironment',executionEnvironment,...
'DispatchInBackground',dispatchInBackground,...
'BatchNormalizationStatistics','moving',...
'ResetInputNormalization',false,...
'CheckpointPath',tempdir);
[detector,info] = trainPointPillarsObjectDetector(cds,detector,options)
While running this code i got the error Error using dlnetwork/initialize
Invalid network.
dlnet = initialize(dlnet);
Caused by:
Layer 'cnn|concatenate': Input size mismatch. Size of input to this layer is different from the expected input size.
Inputs to this layer:
from layer 'cnn|up1|bn' (size 69(S) × 125(S) × 128(C) × 1(B))
from layer 'cnn|up2|bn' (size 70(S) × 126(S) × 128(C) × 1(B))
from layer 'cnn|up3|bn' (size 72(S) × 128(S) × 128(C) × 1(B)) but my training data is in required format as mentoned in the documentation ans = 1×3 cell 1×1 pointCloud 4×9 double 4×1 categorical this are the three coloumns of mytraing data

Réponses (1)

Gagan Agarwal
Gagan Agarwal le 21 Mar 2024
Hi Gaurav
The error you are facing suggests an inconsistency in the size of inputs to the layers within the network architecture. This problem typically occurs when the input size expected by a network layer does not match the size of the input actually provided to that layer.
To resolve this error, you can follow these steps:
  1. Review the network architecture, focusing on the size of input expected by each layer and the actual input size received by every layer.
  2. Verify the expected input resolution of the network and ensure that the preprocessing pipeline outputs the data in the correct format required by the network.

Produits


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by