Why I cannot get results when I detect multiple labels

조회 수: 1 (최근 30일)
Carla Shaw
Carla Shaw 2019년 9월 15일
댓글: Zaime Ali 2020년 9월 27일
after I train FasterRCNN object detector, and use the detector to detect multiple labels, the results did not shown
I cannot figure out why the results not shown in the table. so that I cannot calculate the average precision.
I showed my code
%%
trainingData = apple
numClasses = 3;
numClassesPlusBackground = numClasses + 1;
%%
inputLayer = imageInputLayer([32 32 3]);
filterSize = [3 3];
numFilters = 32;
middleLayers = [
convolution2dLayer(filterSize, numFilters, 'Padding', 1)
reluLayer()
convolution2dLayer(filterSize, numFilters, 'Padding', 1)
reluLayer()
maxPooling2dLayer(3, 'Stride',2)
];
finalLayers = [
fullyConnectedLayer(4)
reluLayer
fullyConnectedLayer(width(trainingData))
softmaxLayer
classificationLayer
];
layers = [
inputLayer
middleLayers
finalLayers
]
options = trainingOptions('sgdm', ...
'MiniBatchSize', 1, ...
'InitialLearnRate', 1e-3, ...
'MaxEpochs', 10, ...
'VerboseFrequency', 200, ...
'CheckpointPath', tempdir);
detector = trainFasterRCNNObjectDetector(trainingData, layers, ...
'NegativeOverlapRange',[0 0.3], ...
'PositiveOverlapRange',[0.6 1]);
%%
numImages = height(trainingData);
% Run detector on each image in the test set and collect results.
results = table('Size',[numImages 3],...
'VariableTypes',{'cell','cell','cell'},...
'VariableNames',{'Boxes','Scores','Labels'});
for i = 1:numImages
%ds = imageDatastore(trainingData.imageFilename{i});
% Read the image.
I = imread(trainingData.imageFilename{i});
% Run the detector.
[bboxes,scores,labels] = detect(detector, I);
I=insertObjectAnnotation(I, 'rectangle', bboxes, scores);
% Collect the results.
results.Boxes{i,1} = bboxes;
results.Scores{i,1} = scores;
results.Labels{i,1} = labels;
end
results=struct2table(resultsStruct);
expectedResults = trainingData(:, 2:4);
[ap, recall, precision] = evaluateDetectionPrecision(results,expectedResults);
figure
xlabel('unripeRecall')
ylabel('unripePrecision')
plot(recall, precision)
grid ON
title(sprintf('Average Precision = %.2f', ap));
  댓글 수: 1
Zaime Ali
Zaime Ali 2020년 9월 27일
Im also stuck in this issue can you please help me too if you found the error

댓글을 달려면 로그인하십시오.

답변 (2개)

Image Analyst
Image Analyst 2019년 9월 15일
What function did you call to show the regions? Did you use insertObjectAnnotation()?
post your script.

Image Analyst
Image Analyst 2019년 9월 16일
You ARE getting results. trainindData is not your results - that is the image datastore used to train your detector. Your results are bboxes.
What table are you talking about?
  댓글 수: 4
Carla Shaw
Carla Shaw 2019년 9월 17일
I tried but still not work, I cannot fogure out why.
Image Analyst
Image Analyst 2019년 9월 18일
Can youi give the complete script, and tell me what kind of image datastore I need to have?

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by