I am trying to add fivecrop to my torchvision.transforms pipeline but as per the doc it returns me a tuple of 5 instead of all the 5 images i want to randomly select one of them and then feed it to the network . If there is any way to do this?
@ptrblck Would you have a look at it?
I’m unsure if I understand the issue correctly, as a tuple
of 5 images would return all images.
To randomly select one of them, you could use torch.randperm
and use it to index the returned images:
transform = transforms.Compose([
transforms.ToPILImage(),
transforms.FiveCrop(size=(10, 10))
])
x = torch.randn(3, 24, 24)
out = transform(x)
out_select = out[torch.randperm(len(out))[0]]
from future import division import torch import math import random from input image , so basically the images generated by each crop are different.