TorchData Augmentations

Hi,

I am new to datapipes and I am unsure how to implement augmentation on images, similar to how I would in the normal dataset class.

I have a datapipe which currently returns an image, and a mask, but I am not sure how to map my transforms.

when i run something like:

  ds_stack = ds_stack.map(
        A.Compose(
  [
  A.HorizontalFlip(p=0.5),
  #A.Rotate(limit=35, p=1.0),
  A.VerticalFlip(p=0.5),
  A.RandomRotate90(p=1),
  A.Transpose(p=0.5),
  A. Normalize(
      mean=[0.5]*15,  ## adjust to number of bands
      std=[0.5]*15,   ## adjust to number of bands
      max_pixel_value=10000,  ### adjust to the max pixel value
  ),
  ToTensorV2()
  ])

i get the error: KeyError: ‘You have to pass data to augmentations as named arguments, for example: aug(image=image)\nThis exception is thrown by iter of MapperIterDataPipe()’

The exception is raised by the function that you pass in. Based on the message, I believe you can wrap a function around it to provide named arguments:

transform = A.Compose(...)

def apply_transform(image):
    return transform(image=image)

dp = dp.map(apply_transform)
1 Like

fantastic, thank you very much Kevin