hoe to evaluate trained faster rcnn detector

3 ビュー (過去 30 日間)
ahmad
ahmad 2023 年 11 月 4 日
回答済み: Maneet Kaur Bagga 2023 年 11 月 14 日
hi everyone
i want ti ecaluate my faster Rcnn detector on testdta set i tried this code but i got error on evaluationobjectdetector
lassID = 1;
metrics = evaluateObjectDetection(detectionResults,testData);
precision = metrics.ClassMetrics.Precision{classID};
recall = metrics.ClassMetrics.Recall{classID}
than i tried this code is aldo so error
testData = transform(testData,@(data)preprocessData(data,inputSize));
detectionResults = detect(detector,testData,'MinibatchSize',10);
% Determine the number of classes in your dataset
num_classes = 5;
% Preallocate arrays to store precision and recall values for all classes
precisions = zeros(1, num_classes);
recalls = zeros(1, num_classes);
% Loop through all class IDs
for classID = 1:num_classes
% Evaluate precision and recall for the current class ID
metrics = fasterRCNNtestdetect(detectionResults, testData);
precision = metrics.ClassMetrics.Precision{classID};
recall = metrics.ClassMetrics.Recall{classID};
% Store precision and recall for the current class
precisions(classID) = precision;
recalls(classID) = recall;

回答 (1 件)

Maneet Kaur Bagga
Maneet Kaur Bagga 2023 年 11 月 14 日
Hi Ahmad,
After reproducing the code at my end, as per my understanding the syntax error is because of the "ClassMetrics" of the "evaluateObjectDetection" function. The metrics.ClassMetrics represents a table and for each class it represents a row, hence to access each class iterate through all the rows and for each row access the "precision" and "recall" property.
Please refer to the following code snippet for better understanding of the workaround.
% Evaluate object detection
metrics = evaluateObjectDetection(detectionResults, groundTruthData);
% Access precision and recall for each class
classMetrics = metrics.ClassMetrics;
% Loop through each class and obtain precision and recall
for classID = 1:numel(classMetrics)
precision = classMetrics(classID).Precision;
recall = classMetrics(classID).Recall;
% Do something with precision and recall for the current class
fprintf('Class %d: Precision = %.2f, Recall = %.2f\n', ...
classID, precision, recall);
end
Please refer to the following MATLAB documentaion specially the "ClassMetrics" section.
Hope this helps!

Community Treasure Hunt

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

Start Hunting!

Translated by