我是靠谱客的博主 默默飞机,这篇文章主要介绍torchvision.transforms.RandomErasing 报错 ‘Image‘ object has no attribute ‘shape‘,现在分享给大家,希望可以做个参考。

参考:https://discuss.pytorch.org/t/attributeerror-image-object-has-no-attribute-shape/149175
原因:transforms.RandomErasing处理tensor,而非image。
解决办法:
将transforms.RandomErasing操作置于**transforms.ToTensor()**之后


"train": transforms.Compose([transforms.RandomResizedCrop(img_size),
transforms.RandomHorizontalFlip(),
transforms.RandomRotation(180),#旋转
transforms.ToTensor(),
transforms.RandomErasing(p=0.5, scale=(0.02, 0.33), ratio=(0.3, 3.3), value=0, inplace=False), #遮挡
transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))]),

最后

以上就是默默飞机最近收集整理的关于torchvision.transforms.RandomErasing 报错 ‘Image‘ object has no attribute ‘shape‘的全部内容,更多相关torchvision.transforms.RandomErasing内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(184)

评论列表共有 0 条评论

立即
投稿
返回
顶部