无法禁用PyTorch中的beta转换警告

ogq8wdun  于 12个月前  发布在  其他
关注(0)|答案(1)|浏览(136)

Win x64、Spyder、Python 3.9、Pytorch 2.0.1+cu117
大量的

C:\Users\sengnr3\.conda\envs\pytorch\Lib\site-packages\torchvision\transforms\v2\__init__.py:54: UserWarning: The torchvision.datapoints and torchvision.transforms.v2 namespaces are still Beta. 
While we do not expect major breaking changes, some APIs may still change according to user feedback. Please submit any feedback you may have in this issue: 
https://github.com/pytorch/vision/issues/6753, and you can also check out https://github.com/pytorch/vision/issues/7319 to learn more about the APIs that we suspect might involve future changes. 
You can silence this warning by calling torchvision.disable_beta_transforms_warning().
      warnings.warn(_BETA_TRANSFORMS_WARNING)

字符串
所以我试着用警告代码中的建议保持沉默,

import torchvision
torchvision.disable_beta_transforms_warning()


但仍然是同样的警告。

n3schb8v

n3schb8v1#

它看起来像禁用v2警告你需要先调用disable_beta_transforms_warning()然后导入v2转换。
例如,以下代码不会禁用警告:

from torchvision.transforms import v2
import torchvision
torchvision.disable_beta_transforms_warning()

字符串
但这段代码做到了:

import torchvision
torchvision.disable_beta_transforms_warning()
from torchvision.transforms import v2


如果你先导入v2 transform,它会发出警告,因为python先导入v2 transform而没有禁用警告。

相关问题