TorchData Augmentations


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 =
  #A.Rotate(limit=35, p=1.0),
  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

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 =
1 Like

fantastic, thank you very much Kevin