R-CNN detector

5 views (last 30 days)
Toni Vukasinovic
Toni Vukasinovic on 4 Apr 2020
I have trained Alexnet via transfer learning for my 4 categories(Bush,Branch,Tree,Rock)...How to make a R-CNN detector that i can use for my new images to detect objects within those categories?
Here is the code i used to train my network.
%% Load a pre-trained, deep, convolutional network
alex = alexnet;
layers = alex.Layers
%% Modify the network to use four categories
layers(23) = fullyConnectedLayer(4);
layers(25) = classificationLayer
%% Set up our training data
allImages = imageDatastore('myImages', 'IncludeSubfolders', true, 'LabelSource', 'foldernames');
[trainingImages, testImages] = splitEachLabel(allImages, 0.8, 'randomize');
%% Re-train the Network
opts = trainingOptions('sgdm', 'InitialLearnRate', 0.001, 'MaxEpochs', 20, 'MiniBatchSize', 64);
myNet = trainNetwork(trainingImages, layers, opts);
%% Measure network accuracy
predictedLabels = classify(myNet, testImages);
accuracy = mean(predictedLabels == testImages.Labels)

Answers (1)

Srivardhan Gadila
Srivardhan Gadila on 7 Apr 2020
Please refer to the following workflow: Create R-CNN Object Detection Network.
The total number of classes the RCNNdetector should detect will be the number of object classes you want to detect plus an additional background class.

Community Treasure Hunt

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

Start Hunting!