Getting the crop parameters used in RandomResizedCrop

Is it possible to get the corresponding crop parameters when an image is transformed by torchvision’s RandomResizedCrop?

-devon

I think it’s not possible to get these parameters after the transformation was applied on the image.
However, you could get the parameters before and apply them using torchvision.transforms.functional.crop manually:

img = transforms.ToPILImage()(torch.randn(3, 224, 224))
crop = transforms.RandomResizedCrop(224)
params = crop.get_params(img, scale=(0.08, 1.0), ratio=(0.75, 1.33))
img_crop = transforms.functional.crop(img, *params)
1 Like