RCNNによる多クラス検出について
Afficher commentaires plus anciens
現在以下のコードにてRCNNによる検出を行っています。テストイメージには検出したい物体が複数写っておりdetectコマンドで複数の物体を同時に検出したいと考えているのですができません。どのように改良を加えれば良いでしょうか
%%Load a pre-trained, deep, convolutional network
net = alexnet;
layersfirst = net.Layers
%%Delete Full Connected Layer
layersTransfer = layersfirst(1:end-3)
objectClasses = {'mouse','keyboard','mug','efan'};
numClassesPlusBackground = numel(objectClasses) + 1;
%%layers
layers = [layersTransfer
fullyConnectedLayer(numClassesPlusBackground,'WeightLearnRateFactor',20,'BiasLearnRateFactor',20)
softmaxLayer
classificationLayer]
%%RCNN
load ('TESTCHANGE.mat')
opts = trainingOptions('sgdm', 'InitialLearnRate', 0.001, 'MaxEpochs', 5, 'MiniBatchSize', 32);
rcnn = trainRCNNObjectDetector(TESTCHANGE,layers,opts,'NegativeOverlapRange',[0 0.3])
%%TEST
imDir = fullfile(matlabroot,'ImageData','TESTCHANGE');
addpath(imDir);
img = imread('TEST.jpg');
[bbox,score,label]=detect(rcnn,img,'MiniBatchSize',32);
[score,idx]=max(score);
bbox = bbox(idx,:);
annotation = sprintf('%s:(Confidence = %f)',label(idx),score)
detectedImg = insertObjectAnnotation(img,'rectangle',bbox,annotation);
figure
imshow(detectedImg)
rmpath(imDir);
どうかよろしくお願いします。
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Computer Vision dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!