Must I have dataset with multiple classes in a single image to train a Faster R-CNN detection network?

6 views (last 30 days)
I am training a Faster R-CNN detection network with a 5-classes dataset consisting total of 2000 images with each image consists of only one class. I did data augmentation and resizing of data using transform function before training the detector. While training the detector, I am getting errors as below:
Invalid transform function defined on datastore.
The cause of the error was:
Error using bboxwarp>iParseInputs (line 131)
The value of 'bboxA' is invalid. Expected input number 1, bboxA, to be integer-valued.
Error in bboxwarp (line 82)
params = iParseInputs(bboxA,tform,ref,varargin{:});
Error in augmentData (line 11)
data{2} = bboxwarp(data{2},tform,rout);
Error in matlab.io.datastore.TransformedDatastore/read (line 148)
data = self.Transforms{ii}(data);
Error in vision.internal.cnn.rcnnDatasetStatistics>readThroughAndGetInformation (line 70)
batch = read(datastore);
Error in vision.internal.cnn.rcnnDatasetStatistics (line 27)
out = readThroughAndGetInformation(datastore, params, layerGraph);
Error in trainFasterRCNNObjectDetector>iCollectImageInfo (line 1637)
imageInfo = vision.internal.cnn.rcnnDatasetStatistics(trainingData, rpnLayerGraph, imageInfoParams);
Error in trainFasterRCNNObjectDetector (line 418)
[imageInfo,trainingData] = iCollectImageInfo(trainingData, fastRCNN, iRPNParamsEndToEnd(params), params);
Error in Contaminants_Detector (line 171)
[detector, info] = trainFasterRCNNObjectDetector(trainingData,lgraph, ...
options,'NegativeOverlapRange',[0 0.3], ...
'PositiveOverlapRange',[0.6 1]);
Is this a problem due to the presence of only one class in each image? Or what is the problem with my code?

Answers (1)

Asvin Kumar
Asvin Kumar on 12 Apr 2020
You can have images with only one class. There is no issue with that.
The issue is with bboxwrap which you used while performing transforms. The transform funciton works by creating a TransformedDatastore object with a list of the Transforms applied to the input datastore which were then applied when you called the trainFasterRCNNObjectDetector function.
As the error reads, it looks like the bbox values in your first argument to the bboxwrap function are not integer valued. It is possible that they are instead of type single or double. That’s what you will have to fix.
Have a look at the following example to see how bboxwrap is used:

Community Treasure Hunt

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

Start Hunting!