필터 지우기
필터 지우기

How to evaluate Trained detector on test dataset?

조회 수: 4 (최근 30일)
Drov
Drov 2024년 5월 12일
댓글: Drov 2024년 5월 17일
Hello,
How can I evaluate Trained detector on test dataset, pelase? Here example code:
tic
detectionResults = detect(Trained_detector, testData, 'MiniBatchSize', 50);
% Evaluate the object detector using average precision metric.
[ap,recall,precision] = evaluateDetectionPrecision(detectionResults, testData);
classID = 1;
figure
plot(recall{classID},precision{classID},'LineWidth',4)
xlabel("recall")
ylabel("accuracy")
grid on
title(sprintf("AP = %.3f",ap(classID)))
toc
Here Error:
Expected I to be one of these types:
double, single, int16, uint16, uint8, logical
Instead its type was matlab.io.datastore.CombinedDatastore.

채택된 답변

T.Nikhil kumar
T.Nikhil kumar 2024년 5월 14일
Hello Drov,
I understand that you are trying to test a detector network on a custom dataset using the ‘detect’ function.
The error message suggests that the ‘detect function’ is expecting images of certain types (e.g., double, single, int16, uint16, uint8, logical), but instead, it received an object of type ‘CombinedDatastore’.
The format of test data argument for ‘detect’ function depends on the type of your trained network. I assume you are using a R-CNN deep learning detector. The ‘detect’ function expects the test data to be a numeric array of images (H-by-W-by-C). You will need to convert the test data from a combined datastore to the required array.
For using the ‘detect’ function, I suggest you to first extract the image data from the ‘combinedDatastore’ object and then detect bounding boxes for each image. You can also accumulate results while doing so. Here is a sample code snippet for the process:
% Read all the data from the combined datsstore
allData = readall(testData);
% Extract the images data
imagesData = allData(:,1);
% preallocate detectionResults
detectionResults = zeros(size(imagesData));
% Loop through the images and store detection results
for i = 1:size(imagesData,1)
imageDetectionResult = detect(Trained_detector, imagesData{i});
detectionResults = [detectionResults imageDetectionResult];
end
For evaluating the performance, you can use ‘evaluateObjectDetection’ function. You can use the combinedDatastore object itself with this function.
Refer to the following documentation for more understanding about:
  1. detect function for YOLOv3 network (look at expected data type for images) - https://www.mathworks.com/help/vision/ref/yolov3objectdetector.detect.html
  2. detect function for RCNN network (look at expected data type for images) - https://www.mathworks.com/help/vision/ref/rcnnobjectdetector.detect.html
  3. evaluateObjectDetection - https://www.mathworks.com/help/vision/ref/evaluateobjectdetection.html
Hope this helps you proceed with your work!
  댓글 수: 1
Drov
Drov 2024년 5월 17일
Hello dear T.Nikhil kumar,
Thanks for your reply. It's help me. But anothe error like this appear:
Dimensions of arrays being concatenated are not consistent.
Error in (line 88)
detectionResults = [detectionResults imageDetectionResult];
I think, detector detected not only one object, but also many objects, so I'm trying to fix this like:
for i = 1:size(imagesData,1)
imageDetectionResult = detect(Trained_detector, imagesData{i});
detectionResults{i} = imageDetectionResult;
end
But another error also appeared:
Unable to perform assignment because brace indexing is not supported for variables of this type.
Can you suggest something please?
Thank you in advance!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by