MATLAB Answers

understand the label store command

11 views (last 30 days)
Matpar
Matpar on 16 Dec 2019
Commented: Dheeraj Singh on 20 Dec 2019
Hi all,
I am really trying to understand this command and it's a bit challenging to see my error. I moved away for a bit, did some googling and still the error is evading me. I reamin nonchalant!
please assist this is my code utilised for FastRCNN training and detction
blds = boxLabelDatastore(trainingData(:,2:end));

  8 Comments

Show 5 older comments
Dheeraj Singh
Dheeraj Singh on 19 Dec 2019
You can first check the version of Matlab.
Refer to the following MatlabAnswer to check your Matlab version:
If its not R2019b please update it because boxLabelDatastore was only introduced in R2019b.
Otherwise please provide the data and the code, to better understand the issue.
Since it is giving the following error:
>> trainFastRCNNObjectDetector
Undefined function or variable 'boxLabelDatastore'
Most probabaly there is an issue with the Matlab version.
Matpar
Matpar on 19 Dec 2019
Hi Dheeraj again and thanks for responding rapidly,
I am working with the R2019b version!
Please see my code for my challenges below and thank you in advance for acknowledging my requests.
%% 1 Loading Data
data = load('rcnnStopSigns.mat', 'stopSigns', 'fastRCNNLayers');
stopSigns = data.stopSigns;
fastRCNNLayers = data.fastRCNNLayers;
%% 2 Add Full Path To Image Files
stopSigns.imageFilename = fullfile(toolboxdir('vision'),'visiondata', ...
stopSigns.imageFilename);
%% 3 Randomly shuffling Data For Training
rng(0);
shuffledIdx = randperm(height(stopSigns));
stopSigns = stopSigns(shuffledIdx,:);
%% 4 Creating ImageDatastore Utilising Table Files
imds = imageDatastore(stopSigns.imageFilename);
%% 5 Creating A BoxLabelDatastore Utilising Label Columns From The Table
blds = boxLabelDatastore(stopSigns(:,2:end));
%% 6 Combining the Datastores
ds = combine(imds, blds);
%% 7 Applying Preprocessing/Resizing Image & Boxes For Predefined Size
ds = transform(ds,@(data)preprocessData(data,[920 968 3]));
%% 8 Setting Network Training Options
options = trainingOptions('sgdm', ...
'MiniBatchSize', 10, ...
'InitialLearnRate', 1e-3, ...
'MaxEpochs', 10, ...
'CheckpointPath', tempdir);
%% 9 Training The Fast R-CNN Detector
frcnn = trainFastRCNNObjectDetector(ds, fastRCNNLayers , options, ...
'NegativeOverlapRange', [0 0.1],'PositiveOverlapRange', [0.7 1]);
%% 10 Testing The Fast R-CNN Detector On Test Image
img = imread('stopSignTest.jpg');
%% 11 Running The Detector Results
detectedImg = insertObjectAnnotation(img,'rectangle',bbox,score);
figure
imshow(detectedImg)
Dheeraj Singh
Dheeraj Singh on 20 Dec 2019
The above code executes in my system till the line:
%% 9 Training The Fast R-CNN Detector
frcnn = trainFastRCNNObjectDetector(ds, fastRCNNLayers , options, ...
'NegativeOverlapRange', [0 0.1],'PositiveOverlapRange', [0.7 1]);
After that it gives error for 'preprocessData' method.
So, the follwoing line runs:
%% 5 Creating A BoxLabelDatastore Utilising Label Columns From The Table
blds = boxLabelDatastore(stopSigns(:,2:end));
So the boxLabelDatastore function is working.
As the example says it uses the following
Make sure they are present in your system.
To check for toolboxes present in your system please follow the below link:
The best way to check that would be to execute the follwoing command on Matlab to run the example:
openExample('deeplearning_shared/DeepLearningFasterRCNNObjectDetectionExample')
If it works fine it means you have all the toolboxes required for implementation.
And for the error about 'preprocessData' function, it is not a built-in function so you need to copy the code from the example, save it and then execute the above code.

Sign in to comment.

Answers (0)

Sign in to answer this question.