I first loaded the image like so:
import numpy as np
import cv2

img = cv2.imread('cat.jpg',1)
image_new=torch.from_numpy(img)

and then I used the code above
and the size of the x is:
torch.Size([1, 576, 1024, 3])