I want to extract image patches from an image with patch size 128 and stride 32, so I have this code, but it gives me an error :
from PIL import Image
img = Image.open("cat.jpg")
x = transforms.ToTensor()(img)
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)
and the error I get is :
RuntimeError: maximum size for tensor at dimension 1 is 3 but size is 128
This is the only method I've found so far. but it gives me this error