I am implementing a faster RCNN network on pytorch. I have followed the next tutorial.
https://pytorch.org/tutorials/intermediate/torchvision_tutorial.html
There are images in which I have more than 100 objects to classify. However, with this tutorial I can only detect a maximum of 100 objects, since the parameter "maxdets" = 100.
Is there a way to change this value to adapt it to my project?
IoU metric: bbox
Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.235
Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.655
Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.105
Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = -1.000
Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.238
Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = -1.000
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.006
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.066
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.331
Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = -1.000
Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.331
Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = -1.000
If only change next param, it would be the problem solved?
cocoeval.Params.setDetParams.maxDets = [1, 10, 100]
Thank you!
"There are images in which I have more than 100 objects to classify."
maxDets = 100 doesn't mean it will classify only 100 images but it refers to % AverageRecall given 100 detections per image
inshort maxDets is realted to metrics not actual no. of images classified.
for more info visit : http://cocodataset.org/#detection-eval
https://github.com/matterport/Mask_RCNN/issues/663
# Limit to max_per_image detections **over all classes**
if number_of_detections > self.detections_per_img > 0:
cls_scores = result.get_field("scores")
image_thresh, _ = torch.kthvalue(
cls_scores.cpu(), number_of_detections - self.detections_per_img + 1
)
keep = cls_scores >= image_thresh.item()
keep = torch.nonzero(keep).squeeze(1)
result = result[keep]
return result
according to this code snippet I found that it checks the no. of detection
so model.roi_heads.detections_per_img=300
is correct for your purpose.
And I haven't found much proper documentation on maxdets but i guess the above code should work.
# non-maximum suppression, independently done per class
keep = box_ops.batched_nms(boxes, scores, labels, self.nms_thresh)
# keep only topk scoring predictions
keep = keep[:self.detections_per_img]
this code snippet says that we can filter out only some top detections we want to have in our model.