【问题标题】:torchvision.transforms.RandomRotation fill argument not workingtorchvision.transforms.RandomRotation 填充参数不起作用
【发布时间】:2021-05-04 23:23:43
【问题描述】:

我正在研究张量,想用torchvision.transforms.RandomRotation 旋转它们并使用fill 选项。

import torch
import torchvision

img1 = torch.rand((1, 16, 16))
img2 = torchvision.transforms.RandomRotation(45, fill=1)(img1)

但是,我总是得到:

Tensor 输入不支持参数填充/填充颜色。填充值为零

它没有被填满。我对torchvision.transforms.RandomPerspective 有同样的问题。 我正在使用 Python 3.8 和 PyTorch 1.7.1。我尝试使用fill=(1,),这似乎是一种解决方法,但它对我不起作用。你知道有什么问题吗?

【问题讨论】:

    标签: python pytorch data-augmentation torchvision


    【解决方案1】:

    您可能使用的是 torchvision v0.8.2 或更早版本。此问题已在 5 个月前在 PR #2904 中修复。如果您没有使用v0.9.0 或更新版本,您将无法在Tensor 输入中使用fill :(

    因此,唯一的解决方案是升级您的 torchvision。

    【讨论】:

    • 不幸的是,我正在使用 torchvision.__version__ '0.8.2'。
    • @user930958 我的错误。他们延迟了交付,PR #2904 仅包含在 v0.9.0 中(请参阅changelog)。因此,问题正是因为您使用的是旧版本。
    • 通过 conda 更新 pytorch 或 torchvision 不起作用,因为它没有更新到最新版本,我没有注意到。但是,删除并重新安装会有所帮助。
    猜你喜欢
    • 2018-01-19
    • 1970-01-01
    • 2012-08-02
    • 2014-10-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多