Why I cannot get results when I detect multiple labels

1 vue (au cours des 30 derniers jours)
Carla Shaw
Carla Shaw le 15 Sep 2019
Commenté : Zaime Ali le 27 Sep 2020
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 commentaire
Zaime Ali
Zaime Ali le 27 Sep 2020
Im also stuck in this issue can you please help me too if you found the error

Connectez-vous pour commenter.

Réponses (2)

Image Analyst
Image Analyst le 15 Sep 2019
What function did you call to show the regions? Did you use insertObjectAnnotation()?
post your script.

Image Analyst
Image Analyst le 16 Sep 2019
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 commentaires
Carla Shaw
Carla Shaw le 17 Sep 2019
I tried but still not work, I cannot fogure out why.
Image Analyst
Image Analyst le 18 Sep 2019
Can youi give the complete script, and tell me what kind of image datastore I need to have?

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by