You could first create the indices, shuffle them, and then slice your images.
Passing both the indices and images to your Dataset you could return a tuple of image and index.
images = []
for i in range(10):
img = transforms.ToPILImage()(torch.randn(3, 600, 600))
images.append(img)
pairs_idx = [[z+y for y in range(2)] for z in range(len(images)-1)]
random.shuffle(pairs_idx)
pairs = [[images[a], images[b]] for a, b in pairs_idx]
HI, Just nice I found this code useful on my case study that I am doing now. Just wondering will this code do the randomcrop on every second images? What if I want to randomcrop based on probability? How can I do that? I am also working on doing data augmentation on tensors rather than images itself. Thank you for your help!
The code is quite old by now but it seems that resample will be active for each second call.
You can sample the crop position, height and width with any method you like and donât need to use self.get_params if that doesnât fit your use case.
I see! Thanks for your advice! It seem to work okay! btw I am still unfamiliar with pytorch forum but uh how do I open a topic when I want to ask smth? haha