Pytorch randomresizedcrop vs zoom_range in datagenerator

Hi everyone,

I have a problem augmenting my image dataset via zooming in or out. I have read that RandomResizedCrop in torchvision.transforms could be an alternative for the zoom_range in keras data generator. However, I am not able to understand how exactly they are different. For example, in RandomResizedCrop we first crop a “random” portion of the image, but I think that the keras data generator does not act on a random portion of the image. Can anyone help me in this regard?

I don’t fully understand how the Keras implementation works as zoom_range seems to be only an argument to a generator, not a transformation.
In any case, if you only want to zoom into the image center, you could use a CenterCrop and Resize transformation sequentially.

Thank you very much for your response.
I want to exactly understand the difference between Keras and Pytorch implementations for zooming in or out through an example:
If I consider that my images are 256 * 256 and the zoom_range in the Keras data generator is 0.2, for example, I think the exact alternative in Pytorch could be as follows:
First, I should CenterCrop the image to a size of (256 * 0.8 = 205, 256 * 0.8 = 205) and then resize it to the original size of 256 * 256.
Is that right?

No, I don’t think this would match what Keras does, as it seems to be a random operation in Keras as seen in the docs:

zoom_range: Float or [lower, upper]. Range for random zoom. If a float, [lower, upper] = [1-zoom_range, 1+zoom_range].

If you specify zoom_range=0.2 I would thus assume the Keras implementation will randomly zoom into the image with a factor randomly samples between [0.8, 1.2].