Borrar filtros
Borrar filtros

Calculating the Mean IoU with our own anchor boxes

6 visualizaciones (últimos 30 días)
Ricky Hartono
Ricky Hartono el 21 de En. de 2021
Respondida: prabhat kumar sharma el 20 de Feb. de 2024
I tried to estimate the number and size of anchor boxes to predict 5 different object classes inside images using this tutorial here https://www.mathworks.com/help/vision/ug/estimate-anchor-boxes-from-training-data.html
I was wondering whether the estimateAnchorBoxes function consider the average anchor boxes prediction for each class or it see the data as a whole (without considering the class), because I realize that one of my image data class is imbalance (5 times compare to the other data) and the result from the estimateAnchorBoxes tend to follow the bounding box size of this class.
Then, I tried to estimate the anchor box for each class and select and combine it manually. However, I want to check the mean IoU for my own anchor boxes selection.
Is it possible to do that?

Respuestas (1)

prabhat kumar sharma
prabhat kumar sharma el 20 de Feb. de 2024
Hi Ricky,
The estimateAnchorBoxes function in MATLAB estimates the size of anchor boxes based on the width and height of the bounding boxes in the training data, considering the data as a whole without discriminating between different object classes. This means that if one class is overrepresented in your dataset, the estimated anchor boxes may be biased towards the sizes of the bounding boxes for that particular class.
To check the mean Intersection over Union (IoU) for your manually selected anchor boxes, you can write a function that compares each of your anchor boxes with each bounding box in the dataset and calculates the IoU. Then, you can average these IoU values to get the mean IoU for your selection.
The below code can give you an idea :
function meanIoU = calculateMeanIoU(anchorBoxes, boundingBoxes)
% Initialize IoU sum
IoUSum = 0;
count = 0;
% Loop over all bounding boxes
for i = 1:size(boundingBoxes, 1)
% Extract the current bounding box
bbox = boundingBoxes(i, :);
% Calculate IoU with each anchor box
for j = 1:size(anchorBoxes, 1)
anchorBox = [0 0 anchorBoxes(j, :)];
IoU = bboxOverlapRatio(bbox, anchorBox, 'Union');
% Add to IoU sum
IoUSum = IoUSum + IoU;
count = count + 1;
end
end
% Calculate mean IoU
meanIoU = IoUSum / count;
end
% Example for the usage of the function.
% anchorBoxes = [width height; width height; ...];
% boundingBoxes = [x y width height; x y width height; ...];
% meanIoU = calculateMeanIoU(anchorBoxes, boundingBoxes);
I hope it helps!

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by