Skip to content

Question about Random Crop transformation parameters  #134

Open

Description

@mkmenta

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!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions