Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about Random Crop transformation parameters #134

Open
mkmenta opened this issue Feb 19, 2021 · 0 comments
Open

Question about Random Crop transformation parameters #134

mkmenta opened this issue Feb 19, 2021 · 0 comments

Comments

@mkmenta
Copy link

mkmenta commented Feb 19, 2021

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant