GOATmessi8 / RFBNet

Receptive Field Block Net for Accurate and Fast Object Detection, ECCV 2018
MIT License
1.41k stars 355 forks source link

Question about Random Crop transformation parameters #134

Open mkmenta opened 3 years ago

mkmenta commented 3 years ago

Hi! First of all thanks for your great job and contribution!

I was checking the code of the data augmentation transforms, specifically the _crop function. But, I have found that in some images it is almost impossible to find a valid crop (according to what I understand), when the image has more than 3 or 4 bboxes.

According to what I see in the code, you decide a minimum and maxium IoU randomly in this list:

mode = random.choice((
            None,
            (0.1, None),
            (0.3, None),
            (0.5, None),
            (0.7, None),
            (0.9, None),
            (None, None),
        ))
...
min_iou, max_iou = mode

Later on you compute the crop (roi variable) and the IoU of the bboxes with the full crop:

roi = np.array((l, t, l + w, t + h))
iou = matrix_iou(boxes, roi[np.newaxis])

and finally you check if all the bboxes have a minimum IoU with the whole crop bigger the randomly selected one:

if not (min_iou <= iou.min() and iou.max() <= max_iou):
            continue

and if they are not, you try again until you reach 50 trials.

However, I think its almost impossible to find a valid crop for images with a couple of bboxes. So, they are never cropped unless we fall in the (None, None) case. E.g. https://cocodataset.org/#explore?id=363917.

The reasons I find are:

  1. The IoU is computed against the whole crop area, so it is difficult to get high IoU values unless the crop is tight around the BBox.
  2. The minimum IoU is required for all the BBoxes. That is, it is always required that the crop takes all the BBoxes of the image.

Am I right? Was this intended somehow?

Thank you so much in advance!