Creating RCNN Detection Using Transfer Learning
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Hi Professionals,
can a professional guide in obtaing the layers, I keep getting this error no matter what i change!
I am lacking some knowledge required for moving forward please assist!
Attach is the label for the files I tried uploading the image folder bit but it too large sorry!
This is my code please assist in pointing me in the right direction, really would like to solve this! it's metally chanllenging when the errors are seemingly invisible!
%% Train R-CNN Stop Sign Detector
% Load training data and network layers.
load('gunx.mat', 'guntr', 'layers')
%% Add the image directory to the MATLAB path.
imDir = fullfile(matlabroot, 'toolbox', 'vision', 'visiondata','gunsGT');
addpath(imDir);
%% Set network training options to use mini-batch size of 32 to reduce
% GPU/CPU memory usage. Lower the InitialLearnRate to reduce the rate at which
% network parameters are changed. This is beneficial when fine-tuning a
% pre-trained network and prevents the network from changing too rapidly.
options = trainingOptions('sgdm','MiniBatchSize', 32,'InitialLearnRate', 1e-6,'MaxEpochs', 10);
%% Train the R-CNN detector. Training can take a few minutes to complete.
rcnn = trainRCNNObjectDetector(gunsGT, layers, options, 'NegativeOverlapRange', [0 0.3]);
%% Test the R-CNN detector on a test image.
img = imread('Gun00012.jpg');
[bbox, score, label] = detect(rcnn, img, 'MiniBatchSize', 32);
%% Display strongest detection result.
[score, idx] = max(score);
bbox = bbox(idx, :);
annotation = sprintf('%s: (Confidence = %f)', label(idx), score);
detectedImg = insertObjectAnnotation(img, 'rectangle', bbox, annotation);
figure
imshow(detectedImg)
%% Remove the image directory from the path.
rmpath(imDir);
This is my errors:
>> guntest2
Warning: Variable 'layers' not found.
> In guntest2 (line 3)
Undefined function or variable 'gunsGT'.
Error in guntest2 (line 16)
rcnn = trainRCNNObjectDetector(gunsGT, layers, options, 'NegativeOverlapRange', [0 0.3]);
0 Commenti
Risposte (1)
Shashank Gupta
il 20 Gen 2020
Hi Matpar,
I am not sure what “gunx.mat” file contains, but by looking at the error message, one can decode that the variable name “layers” not been found. Can you check the mat file once more, does it contain the required “layers” variable?
The second error message is related to “gunsGT” which I do not have any access to, but again looking at the error it seems like gunsGT is not the right argument which needs to be passed in trainRCNNObjectDetector, this detector function must have a datastore or {image,label} array as the first argument.
Also if you want me to further investigate, attach all the required mat file and function which is used.
I hope this helps.
4 Commenti
Demet Hanife
il 26 Gen 2021
testImage = imread('F:\a.jpg');
[bboxes, score, label] = detect(rcnn, testImage, 'MiniBatchSize', 128)
T = 0.9;
idx = score >= T;
s = score(idx);
lbl = label(idx);
bbox = bboxes(idx, :);
for ii = 1 : size(bbox, 1)
annotation = sprintf('%s:()', lbl(ii));
outputImage = insertObjectAnnotation(outputImage, 'rectangle', bbox(ii,:), annotation);
end
figure
imshow(outputImage)
I don't know if it helps, but I'm doing a face recognition test in a 12-person classroom with these codes. I'm inexperienced in Matlab. Maybe it gives an idea.
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!