Why cannot the Faster-RCNN run but Fast-RCNN can with the same object detection data and based on the samples from Matlab?
Info
This question is closed. Reopen it to edit or answer.
Show older comments
Hi there,
Recently, I have being learned how to use deep learning to detect object. I am confused a lot with a question about Faster-RCNN.
Why cannot the Faster-RCNN run but Fast-RCNN can with the same object detection data and based on the samples from Matlab?
Below are the part of codes for the Faster-RCNN rand Fast-RCNN.
%% Train Faster R-CNN building Detector
idx = floor(0.6 * height(wlDataset));
trainingData = wlDataset(1:idx,:);
testData = wlDataset(idx:end,:);
inputLayer = imageInputLayer([256 256 3]);
filterSize = [3 3];
numFilters = 32;
% Create the middle layers.
middleLayers = [
convolution2dLayer(filterSize, numFilters, 'Padding', 1)
reluLayer()
convolution2dLayer(filterSize, numFilters, 'Padding', 1)
reluLayer()
maxPooling2dLayer(3, 'Stride',2)
];
finalLayers = [
% Add a ReLU non-linearity.
reluLayer()
fullyConnectedLayer(width(wlDataset))
% Add the softmax loss layer and classification layer.
softmaxLayer()
classificationLayer()
];
% Combine the input, middle, and final layers.
layers = [
inputLayer
middleLayers
finalLayers
];
optionsStage1 = trainingOptions('sgdm', ...
'MaxEpochs', 10, ...
'MiniBatchSize', 1, ...
'InitialLearnRate', 1e-3, ...
'CheckpointPath', tempdir);
% Options for step 2.
optionsStage2 = trainingOptions('sgdm', ...
'MaxEpochs', 10, ...
'MiniBatchSize', 1, ...
'InitialLearnRate', 1e-3, ...
'CheckpointPath', tempdir);
% Options for step 3.
optionsStage3 = trainingOptions('sgdm', ...
'MaxEpochs', 10, ...
'MiniBatchSize', 1, ...
'InitialLearnRate', 1e-3, ...
'CheckpointPath', tempdir);
% Options for step 4.
optionsStage4 = trainingOptions('sgdm', ...
'MaxEpochs', 10, ...
'MiniBatchSize', 1, ...
'InitialLearnRate', 1e-3, ...
'CheckpointPath', tempdir);
options = [
optionsStage1
optionsStage2
optionsStage3
optionsStage4
];
%%
doTrainingAndEval = true;
if doTrainingAndEval
% Set random seed to ensure example training reproducibility.
rng(1);
% Train Faster R-CNN detector. Select a BoxPyramidScale of 1.2 to allow
% for finer resolution for multiscale object detection.
fasterrcnn = trainFasterRCNNObjectDetector(trainingData, layers, options, ...
'NegativeOverlapRange', [0 0.3], ...
'PositiveOverlapRange', [0.6 1], ...
'NumRegionsToSample', [256 128 256 128], ...
'BoxPyramidScale', 1.2);
else
% Load pretrained detector for the example.
% detector = data.detector;
end
============================================
%% Train Fast R-CNN building Detector
clc;
wlDataset = wlData;
idx = floor(0.6 * height(wlDataset));
trainingData = wlDataset(1:idx,:);
testData = wlDataset(idx:end,:);
inputLayer = imageInputLayer([32 32 3]);
filterSize = [3 3];
numFilters = 32;
% Create the middle layers.
middleLayers = [
convolution2dLayer(filterSize, numFilters, 'Padding', 1)
reluLayer()
convolution2dLayer(filterSize, numFilters, 'Padding', 1)
reluLayer()
maxPooling2dLayer(3, 'Stride',2)
];
finalLayers = [
fullyConnectedLayer(64)
reluLayer()
fullyConnectedLayer(width(wlDataset))
softmaxLayer()
classificationLayer()
];
layers = [
inputLayer
middleLayers
finalLayers
];
options = trainingOptions('sgdm', ...
'MiniBatchSize', 1, ...
'InitialLearnRate', 1e-3, ...
'MaxEpochs', 10, ...
'CheckpointPath', tempdir);
frcnn = trainFastRCNNObjectDetector(trainingData, layers, options);
Answers (0)
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!