将数据加载器中的图像拆分为补丁
使用 Fashion mnist 数据集,我不想只将单个图像分割为补丁,而是将所有图像分割为多个图像。
我已经看到了函数unfold(),但我认为这只适用于单个图像
mnist_train = torchvision.datasets.FashionMNIST(
root="../data", train=True,
transform=transforms.Compose([transforms.ToTensor()]), download=True)
x = mnist_train[0][0][-1, :, :]
x = x.unfold(0, 7, 7).unfold(1, 7, 7)
x.shape
如何为所有图像制作不重叠的补丁(任意数量以保持简单)?
将不胜感激任何帮助。谢谢!
Using the Fashion mnist dataset, I don't want to just split a single image into patches but rather all of images.
I've seen the function unfold() but I think this only works for a single image
mnist_train = torchvision.datasets.FashionMNIST(
root="../data", train=True,
transform=transforms.Compose([transforms.ToTensor()]), download=True)
x = mnist_train[0][0][-1, :, :]
x = x.unfold(0, 7, 7).unfold(1, 7, 7)
x.shape
How do I make non-overlapping patches (of any number to keep it simple) for all images?
Would appreciate any help. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以创建自定义转换以将所有图像分割成多个补丁。大致如下:
You can create a custom transform to split all images into multiple patches. Something along the lines of: