Filter löschen
Filter löschen

Training data from a read of the input datastore contains invalid bounding boxes?

11 Ansichten (letzte 30 Tage)
Hello guys i'm trying this code and i don't know what to do to fix the problem
data = load('Damagevehicle.mat');
trainingData = data.Damaaaage;
rng(0);
shuffledIdx = randperm(height(trainingData));
trainingData = trainingData(shuffledIdx,:);
imds = imageDatastore(trainingData.imageFilename);
blds = boxLabelDatastore(trainingData(:,2:end));
ds = combine(imds, blds);
net = load('yolov2VehicleDetector.mat');
lgraph = net.lgraph;
lgraph.Layers;
options = trainingOptions('sgdm','InitialLearnRate',0.001,...
'Verbose',true,'MiniBatchSize',32,'MaxEpochs',30,...
'Shuffle','never','VerboseFrequency',30,...
'CheckpointPath',tempdir);
[detector,info] = trainYOLOv2ObjectDetector(ds,lgraph,options);
The error i got:
Invalid transform function defined on datastore.
The cause of the error was:
Error using vision.internal.cnn.validation.checkTrainingBoxes (line 12)
Training data from a read of the input datastore contains invalid bounding boxes. Bounding boxes must be non-empty,
fully contained within their associated image and must have positive width and height. Use datastore transform method
and remove invalid bounding boxes.
Error in vision.internal.cnn.yolo.validateImagesAndBoxesTransform (line 22)
vision.internal.cnn.validation.checkTrainingBoxes(images, boxes);
Error in
trainYOLOv2ObjectDetector>@(data)vision.internal.cnn.yolo.validateImagesAndBoxesTransform(data,params.InputSize) (line
285)
transformFcn = @(data)vision.internal.cnn.yolo.validateImagesAndBoxesTransform(data,params.InputSize);
Error in matlab.io.datastore.TransformedDatastore/applyTransforms (line 607)
data = ds.Transforms{ii}(data);
Error in matlab.io.datastore.TransformedDatastore/read (line 222)
[data, info] = ds.applyTransforms(data, info);
Error in nnet.internal.cnn.DataLoader/manageReadQueue (line 182)
data = read(self.Datastore);
Error in nnet.internal.cnn.DataLoader/readAhead (line 213)
manageReadQueue(self);
Error in nnet.internal.cnn.DataLoader (line 81)
readAhead(self);
Error in nnet.internal.cnn.GeneralDatastoreDispatcher (line 275)
this.DataLoader = nnet.internal.cnn.DataLoader(ds,...
Error in nnet.internal.cnn.DataDispatcherFactory.createDataDispatcherMIMO (line 186)
nnet.internal.cnn.GeneralDatastoreDispatcher( ...
Error in vision.internal.cnn.trainNetwork>iCreateTrainingDataDispatcher (line 208)
dispatcher = nnet.internal.cnn.DataDispatcherFactory.createDataDispatcherMIMO( ...
Error in vision.internal.cnn.trainNetwork (line 46)
trainingDispatcher = iCreateTrainingDataDispatcher(ds, mapping, trainedNet,...
Error in trainYOLOv2ObjectDetector>iTrainYOLOv2 (line 434)
[yolov2Net, info] = vision.internal.cnn.trainNetwork(...
Error in trainYOLOv2ObjectDetector (line 198)
[net, info] = iTrainYOLOv2(ds, lgraph, params, mapping, options, checkpointSaver);
Error in final1 (line 17)
[detector,info] = trainYOLOv2ObjectDetector(ds,lgraph,options);

Antworten (1)

T.Nikhil kumar
T.Nikhil kumar am 9 Okt. 2023
Hey Hind,
As per my understanding, you are trying to train a pretrained YOLOv2 Object Detector network on your own dataset and are facing an invalid bounding box error.
The error message explains that the ‘ds’ datastore contains invalid bounding boxes. The values of valid bounding boxes should be finite, positive, non-fractional, non-NaN and should be within the image boundary with a positive height and width.
This means that the dataset is polluted and requires cleaning i.e any invalid samples in here must either be discarded or fixed for proper training.
You can apply the ‘transform’ function on the ‘ds‘ datastore and define your own transformation function to remove/modify such invalid bounding boxes.
You can refer to the ‘@fcn’ input argument section in the following documentation to understand more about implementation of custom transformation function.
You can refer to a similar implementation of a custom dataset validation function ‘validateInputData.m’ in the ‘Object Detection using YOLOv3 network’ example attached below. (Open the example using ‘Copy Command’ to view the definition of the function)
Hope this helps you proceed further in your work!

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by