question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Augment Keypoints not always correct

See original GitHub issue

Hi!

Thanks a lot for the library, it really works well. The only thing I have issues with is the keypoint augmentation, which works sometimes but in other cases it returns a set of negative coordinate values which are then of course not plotted inside the image when I use ‘draw_on_image’ and show it using matplotlib afterwards. I’m currently using this augmentation sequence:

seq = iaa.Sequential([
    iaa.Fliplr(0.5), # horizontally flip 50% of the images
    iaa.Flipud(0.5), # vertically flip 50% of all images
    #iaa.GaussianBlur(sigma=(0, 3.0)), # blur images with a sigma of 0 to 3.0
    iaa.Affine(
            scale={"x": (0.8, 1.2), "y": (0.8, 1.2)}, # scale images to 80-120% of their size, individually per axis
            translate_px={"x": (-16, 16), "y": (-16, 16)}, # translate by -16 to +16 pixels (per axis)
            rotate=(-45, 45), # rotate by -45 to +45 degrees
            shear=(-16, 16), # shear by -16 to +16 degrees
            order=ia.ALL, # use any of scikit-image's interpolation methods
            #cval=(0, 1.0), # if mode is constant, use a cval between 0 and 1.0
            #mode=ia.ALL # use any of scikit-image's warping modes (see 2nd image from the top for examples)
        )
    ],
    random_order=True # do all of the above in random order
)

seq_det = seq.to_deterministic() # call this for each batch again, NOT only once at the start

For example, when I use this input image:

image

I get results like this:

image

Does anyone have an idea what could be the problem?

Thanks a lot!

UPDATE: It seems like the keypoint augmentation only works if a single command is used in iaa.Affine() at once. If use several, only the first is use to augment keypoints. What works is to use several iaa.Affine() commands in series, with each containing a different image manipulation, which is fine for now.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
HassanBinHarooncommented, Dec 12, 2022

Hi aleju, I am trying to augment images with keypoints How can I deal with missing key points. should I pass them in as -1. How can I prevent images/keypoints from going out of the frame while rotating images? Keeping them in the frame and rotating them seq = iaa.Sequential([ iaa.Multiply((0.5, 1.5)), iaa.Sometimes(0.2, iaa.GaussianBlur(sigma=(0, 0.5))), iaa.Fliplr(1.0), iaa.Affine(rotate=(-7,7),)], random_order=True)

One way of fixing it is to apply a check and if the coordinates become greater than the frame dimensions (while rotating) limit them to the maximum value.

0reactions
mukeshnarendran7commented, Jan 24, 2022

Hi aleju, I am trying to augment images with keypoints How can I deal with missing key points. should I pass them in as -1. How can I prevent images/keypoints from going out of the frame while rotating images? Keeping them in the frame and rotating them seq = iaa.Sequential([ iaa.Multiply((0.5, 1.5)), iaa.Sometimes(0.2, iaa.GaussianBlur(sigma=(0, 0.5))), iaa.Fliplr(1.0), iaa.Affine(rotate=(-7,7),)], random_order=True)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Keypoints augmentation - Albumentations Documentation
After the augmentation, some keypoints may become invisible because they will be located outside of the augmented image's visible area. For example, if...
Read more >
Examples: Keypoints — imgaug 0.4.0 documentation
The following example loads an image and places four keypoints on it. The image is then augmented to be brighter, slightly rotated and...
Read more >
Facial Keypoints Detection: Image and Keypoints Augmentation
First, we do some augmentation where keypoints are not really affected by them. Using Imgaug library, we will add Gaussian Blurring and ...
Read more >
In Colab doing image data augmentation with "imgaug" is not ...
I found it was a version problem. In Colab the library imgaug comes with a version 0.2.9 but this version produces these undesired...
Read more >
Data augmentation Techniques - OpenGenus IQ
For reliable predictions, the deep learning models often require a lot of training data, which is not always available. Therefore, the existing data...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found