【发布时间】:2020-08-22 02:59:24
【问题描述】:
我想从补丁大小为 128、步幅为 32 的图像中提取图像补丁,所以我有这段代码,但它给了我一个错误:
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)
我得到的错误是:
RuntimeError: maximum size for tensor at dimension 1 is 3 but size is 128
这是迄今为止我发现的唯一方法。但它给了我这个错误
【问题讨论】:
标签: python image-processing pytorch