Why do you want to perform the self.transform() operation on all images every time when the __getitem__() of the dataloader is called? You’re required to do the transform operation only on self.images[x] and self.labels[x]. It’s not wrong, but it’s not a good programming practice as you’re doing a redundant operation. Try to change your __getitem__() to the following definition:
def __getitem__(self, x):
        img, label = self.images[x], self.labels[x]
        sample = {'image': img, 'landmarks': label}

        if self.transform:
            sample = self.transform(sample)
        img = sample['image']
        label = sample['landmarks']

        return img, label