albumentations icon indicating copy to clipboard operation
albumentations copied to clipboard

CoarseDropout removes keypoints even if remove_invisible=False

Open tscu-vid opened this issue 2 years ago • 4 comments

🐛 Bug

If the keypoint is below the removed pixels it is not included in the keypoints list, even if the remove_invisible=False is set

To Reproduce

Snippet that reproduce the error:

aug_function = A.Compose([A.CoarseDropout(max_holes=1, max_height=64, max_width=64, p=1),
                              ToTensorV2()], keypoint_params=A.KeypointParams(format='xy',
                                                                  remove_invisible=False,
                                                                  label_fields=['class_labels']))

    while True:
        keypoints = [(10, 30),
                     (50, 90),
                     (150, 130),
                     (210, 230)]
        key_out = aug_function(image=image, keypoints=keypoints, class_labels=class_labels)['keypoints']
        if len(key_out) == 4:
            print('OK')
        elif len(key_out) != 4:
            print('Error')
            break

It returns the following for a run (of course is random the number of OK)

OK
OK
OK
OK
OK
OK
OK
OK
OK
Error

Expected behavior

I expect that the keypoint is returned even if lies where the removed pixels are

Environment

  • Albumentations version 1.3.1:
  • Python version 3.7
  • OS Linux
  • albumentations installed with pip:

tscu-vid avatar Aug 03 '23 15:08 tscu-vid

Not sure why this hasn't been fixed yet.

Y-T-G avatar Nov 03 '23 15:11 Y-T-G

Not yet fixed in albumentations==1.4.3. For those who want to use this augmentation with remove_invisible=False, I share my workaround.

preproc = A.Compose([
    A.CoarseDropout(...),
    ...,
    ], keypoint_params=A.KeypointParams(format='xy', remove_invisible=False)
)

# remove_invisible not working in CoarseDropout
pypass = A.NoOp()
for transform in preproc.transforms:
    if transform.__class__.__name__=='CoarseDropout':
        transform.apply_to_keypoints = pypass.apply_to_keypoints

saerojw avatar Apr 09 '24 18:04 saerojw

Will look into that.

ternaus avatar Apr 09 '24 20:04 ternaus

Hello! Any progress with this issue? Still appears in 1.4.8

Dentikka avatar Jun 02 '24 15:06 Dentikka