Now it’s giving me this error:
RuntimeError: maximum size for tensor at dimension 1 is 3 but size is 128

and the shape of x is :
torch.Size([1, 3, 576, 1024])

and my code is :
from PIL import Image 

img = Image.open("cat.jpg")
x = torch.from_numpy(np.array(img))
x = x.permute(2, 0, 1)

x = x.unsqueeze(0)

size = 128 # patch size
stride = 32 # patch stride
patches = x.unfold(1, size, stride).unfold(2, size, stride).unfold(3, size, stride)
print(patches.shape)