Random cropping

I have image with different image size, I want to add random cropping in my data_transform part in such a way that it will random crop 60% of the original images and then resize.
I used transforms.RandomResizedCrop(256). But is it mean that it will always crop the size 256?

according to the documentation 256 means, that the output image will have side lengths of 256 pixels. The original random cropping is determined by the other parameters scale and ratio.

is it possible that e output image will have side lengths of 60% of the original image? suppose the image length is 1024 * 1024 then the cropped image will be 615615 or if the original image size is 512 512 it will be 307*307.

My understanding is, if we look at the function

torchvision.transforms.RandomResizedCrop(size, scale=(0.08, 1.0), ratio=(0.75, 1.3333333333333333), interpolation=2)

That the image will be randomly cropped between 0.08 to 1 of the original, then given a random aspect ratio of 0.75 to 1 1/3. Then this final image is RESIZED to 256.

So taking your example, yes, if the original image is 1024 * 1024, it can be cropped down to 60%, then a random aspect ratio is applied, and then it is finally resized to 256 (if you set size=256 in the function).

You can of course double check all of this by putting through some images and checking the outputs.

EDIT: the interplay between aspect ratio and scale are somewhat non-obvious tbh. On second reading of the source code it seems that the AREA of the image is scaled down, and then this is fit the an aspect ratio, and then finally resized to 256 *256.

So in your example scaling the image by 60% would mean (keeping aspect ratio at 1), each side would be: sqrt(0.6) * 1024.