[Python] Albumentations does not augment images equally

Discussão em 'Python' iniciado por Stack, Maio 22, 2025.

  1. Stack

    Stack Membro Participativo

    I have a small augmentation pipeline where I want to augment two images in the exact same way. With my current code, however, even the same image has a different augmentation, even though I insert them into the same transforms function. I am not sure what I did wrong here. I appreciate any help. Thanks in advance!

    IMAGE_SIZE = (224,224)

    transform_moving = A.Compose([
    A.Resize(height=IMAGE_SIZE[0] + 16, width=IMAGE_SIZE[1] + 16),
    A.RandomCrop(height=IMAGE_SIZE[0], width=IMAGE_SIZE[1]),
    A.Rotate(limit=10, p=1.0, border_mode=cv2.BORDER_CONSTANT),
    ToTensorV2()
    ],
    additional_targets={"image1": "image"})

    class VisaDataset_test(Dataset):
    def __init__(self, image_paths, transform_moving):
    self.images=os.listdir(image_paths)
    self.image_paths = image_paths
    self.transform_moving = transform_moving

    def __len__(self):
    return len(self.images)

    def __getitem__(self, idx):
    image_name=os.path.join(self.image_paths, self.images[idx])

    image = np.array(Image.open(image_name).convert('RGB')).astype(np.float32)/255

    image_moving_transformed = self.transform_moving(image=image, image1=image)

    image_moving_rgb = image_moving_transformed['image']
    image_moving_gray = image_moving_transformed['image1']

    return image_moving_rgb, image_moving_gray


    [​IMG]

    Continue reading...

Compartilhe esta Página