Threshold For confidence score

4 views (last 30 days)
Abdussalam Elhanashi
Abdussalam Elhanashi on 8 Oct 2019
Hi Guys
I would like if possible how to make this Threshold for Evaluation and validation of created R-CNN object Detector, i tried to make it in the attached scripts but it does not work, I want to make Threshold for score that like below 0.58 that score and bboxes should not be appeared in results
i tried the below code but i got the error
Herein the code:-
smokedetection = selectLabels(gTruth,'alarm');
if ~isfolder(fullfile('EvaluationData'))
mkdir EvaluationData
evaluationData = objectDetectorTrainingData(gTruth,...
imds = imageDatastore(fullfile('EvaluationData'));
numImages = height(evaluationData);
result(numImages,:) = struct('Boxes',[],'Scores',[]);
for i = 1:numImages
% Read Image
I = readimage(imds,i);
% Detect the object of interest
[bboxes, scores] = detect(detector,I,'MiniBatchSize', 32);
% Store result
result(i).Boxes = bboxes;
T = 0.58; % Define threshold here
idx = scores >= T;
result(i).Scores = scores(idx);
% Convert structure to table
results = struct2table(result);
overlap = 0.1;
% Evaluate Metrics
[ap,recall,precision] = evaluateDetectionPrecision(results...
[am,fppi,missRate] = evaluateDetectionMissRate(results,evaluationData(:,2),overlap);
% and herein the error i got
Error using vision.internal.detector.evaluationInputValidation>checkDetectionResultsTable (line 66)
Invalid score value in row 1 of the detection results table: Expected input to be an array with number of
elements equal to 8.
Error in vision.internal.detector.evaluationInputValidation (line 6)
checkDetectionResultsTable(detectionResults, groundTruth, mfilename);
Error in evaluateDetectionPrecision (line 94)
vision.internal.detector.evaluationInputValidation(detectionResults, ...
Error in Evaluationthedetector (line 33)
[ap,recall,precision] = evaluateDetectionPrecision(results...
% Looking for your assistance

Answers (1)

Harsha Priya Daggubati
Harsha Priya Daggubati on 11 Oct 2019
I suspect the issue is due to the threshold you are using, try storing the bounding boxes in results based on the threshold.
T = 0.58; % Define threshold here
idx = scores >= T;
result(i).Boxes = bboxes(idx);
result(i).Scores = scores(idx);
Hope this helps!


Community Treasure Hunt

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

Start Hunting!

Translated by