Label and image are the same when augument data in problem reconstruct image

I am doing noise restoration, I have 1 set of images for input and one set of images for labels, but when I augment the data with pytorch, when I visualize a batch, the images and labels are different, although it is still the same image but if i do the crop it will be two different areas which is not what i really want.

class GAN_DATASET(Dataset):
  def __init__(self, ImageFolder, LabelFolder, data_transforms):
    self.transforms = data_transforms
    self.list_image = []
    self.list_label = []
    for i in os.listdir(ImageFolder):

    for i in os.listdir(LabelFolder):

    self.root_hazy_image = os.path.join(ImageFolder)
    self.root_hazy_label = os.path.join(LabelFolder)
    self.file_len = len(self.list_image)

  def __getitem__(self, index, is_train=True):
      hazy = + self.list_image[index])
      hazy = self.transforms(hazy)
      label = + self.list_label[index])
      label = self.transforms(label)
      name = self.list_image[index]
      return hazy,label,name
  def __len__(self):
      return self.file_len 

If I understand your use case correctly, you would like to apply the same random transformations to the image and target tensors.
In this case you could use the functional API as described in this example.

1 Like