How can I use pytorch to effectively zoom into the image?

Previously to zoom into an image I used the following (example) code:

import numpy as np
import cv2

image = np.zeros([64,64)]
image[10:-10,10:-10] = 1

# zoom into image:
imageZoomIn = cv2.resize(image[1:-1,1:-1] , (64,64))
#zoom out:
imageZoomOut = cv2.resize(image , (65,65))[1:-1, 1:-1)
#multiples Zooms:

imageBigZoom = image
for i in range(zoomScale):
    imageBigZoom = cv2.resize(imageBigZoom [1:-1,1:-1] , (64,64))

Is ther a way to do this effectively in pytorch with whole batches? I want to train my NN with distorted data, which can be bigger or smaller than it is supposed to be.

I think you could use transforms.Crop followed by transforms.Resize (or vice versa) to achieve the same results as in your current code snippet.