0

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!

Jose David
  • 39
  • 9

1 Answers1

2

"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

Tensorboard graph recall

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.

deepak sen
  • 437
  • 4
  • 13
  • 1
    Okey. What I wanted to say is that I have **more than 100 objects of the same class per image.** I have found a parameter that allows my model to detect more than 100 objects. `model.roi_heads.detections_per_img=300` Is this correct for my purpose? I don't know if the training of Faster RCNN is correct if only I change the before parameter. Do you think I should also change the "maxdets" parameter in metrics for everything to work properly? Thank you! – Jose David May 06 '20 at 10:08
  • Perfect. I suposse that the first code snippet belonging to [link](https://github.com/megvii-model/DetNAS/blob/master/maskrcnn_benchmark/modeling/roi_heads/box_head/inference.py). I have tried to change the parameter `model.roi_heads.detections_per_img`, and efectively, my model detect more than 100 objects, and lees than the input number. The second snippet code, is it used to delete detected objects if these don't exceed certain threshold? There is few information about maxdets, you're right! – Jose David May 06 '20 at 22:20
  • "The second snippet code, is it used to delete detected objects if these don't exceed certain threshold? " yeah I guess the algorithm detects a lot of objects and we can get the top K no. of objects which we want. – deepak sen May 07 '20 at 10:27