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

Apply same augmentation to different images #22

Open
elenadoe opened this issue Feb 3, 2023 · 0 comments
Open

Apply same augmentation to different images #22

elenadoe opened this issue Feb 3, 2023 · 0 comments

Comments

@elenadoe
Copy link

elenadoe commented Feb 3, 2023

Thank you for this very valuable tool! I'm working on an image-to-image translation task, where I would like to apply the same transformations (augmentations) to input and ground truth images. Is there any way to do this?

I thought that retrieving one augmentation instance per (input, ground truth) tuple might solve the issue. To test this, I entered an (input, input) tuple into the following code and tested whether the augmented images in data_aug are equal. However, this program returns False (although the images visually look the same). This was programmed using 3D scans and volumentations-3D.

def get_augmentation(patch_size):
    return Compose([
        Rotate((-15, 15), (0, 0), (0, 0), p=0.5),
        ElasticTransform((0, 0.25), interpolation=2, p=0.1),
        Flip(0, p=0.5),
    ], p=1.0)

aug = get_augmentation((79, 95, 79))  # 79, 95, 79 is the whole image, not a patch

data = {'image': np.array([input_img, input_img])}
data_aug = aug(**data)
img = data_aug['image']

print((img[0] == img[1]).all())  # this returns False

Moreover, sometimes one of the augmented images is blank. Could there be a mistake in the provided code, which causes this issue?

Thank you in advance and best wishes
Elena

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