Why I cannot get results when I detect multiple labels

1 visualización (últimos 30 días)
Carla Shaw
Carla Shaw el 15 de Sept. de 2019
Comentada: Zaime Ali el 27 de Sept. de 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 comentario
Zaime Ali
Zaime Ali el 27 de Sept. de 2020
Im also stuck in this issue can you please help me too if you found the error

Iniciar sesión para comentar.

Respuestas (2)

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

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

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by