RCNNによる多クラス検出について
Mostrar comentarios más antiguos
現在以下のコードにて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);
どうかよろしくお願いします。
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Computer Vision en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!