Unverified Commit 276ee2ae authored by Nicolas Hug's avatar Nicolas Hug Committed by GitHub
Browse files

Add a removable warning in torchvision.transforms.v2 and torchvision.datapoints (#7270)

parent cb5f7835
...@@ -3,9 +3,13 @@ import random ...@@ -3,9 +3,13 @@ import random
import numpy as np import numpy as np
import pytest import pytest
import torch import torch
import torchvision
from common_utils import CUDA_NOT_AVAILABLE_MSG, IN_FBCODE, IN_OSS_CI, IN_RE_WORKER, OSS_CI_GPU_NO_CUDA_MSG from common_utils import CUDA_NOT_AVAILABLE_MSG, IN_FBCODE, IN_OSS_CI, IN_RE_WORKER, OSS_CI_GPU_NO_CUDA_MSG
torchvision.disable_beta_transforms_warning()
def pytest_configure(config): def pytest_configure(config):
# register an additional marker (see pytest_collection_modifyitems) # register an additional marker (see pytest_collection_modifyitems)
config.addinivalue_line("markers", "needs_cuda: mark for tests that rely on a CUDA device") config.addinivalue_line("markers", "needs_cuda: mark for tests that rely on a CUDA device")
......
...@@ -95,3 +95,19 @@ def get_video_backend(): ...@@ -95,3 +95,19 @@ def get_video_backend():
def _is_tracing(): def _is_tracing():
return torch._C._get_tracing_state() return torch._C._get_tracing_state()
_WARN_ABOUT_BETA_TRANSFORMS = True
_BETA_TRANSFORMS_WARNING = (
"The torchvision.datapoints and torchvision.transforms.v2 namespaces are still Beta. "
"While we will try our best to maintain backward compatibility, "
"some APIs or behaviors might change without a deprecation cycle. "
"To help us improve these new features, please provide your feedback "
"here: https://github.com/pytorch/vision/issues/6753."
"You can silence this warning by calling torchvision.disable_beta_transform_warning()."
)
def disable_beta_transforms_warning():
global _WARN_ABOUT_BETA_TRANSFORMS
_WARN_ABOUT_BETA_TRANSFORMS = False
...@@ -5,3 +5,10 @@ from ._mask import Mask ...@@ -5,3 +5,10 @@ from ._mask import Mask
from ._video import _TensorVideoType, _TensorVideoTypeJIT, _VideoType, _VideoTypeJIT, Video from ._video import _TensorVideoType, _TensorVideoTypeJIT, _VideoType, _VideoTypeJIT, Video
from ._dataset_wrapper import wrap_dataset_for_transforms_v2 # type: ignore[attr-defined] # usort: skip from ._dataset_wrapper import wrap_dataset_for_transforms_v2 # type: ignore[attr-defined] # usort: skip
from torchvision import _BETA_TRANSFORMS_WARNING, _WARN_ABOUT_BETA_TRANSFORMS
if _WARN_ABOUT_BETA_TRANSFORMS:
import warnings
warnings.warn(_BETA_TRANSFORMS_WARNING)
...@@ -45,3 +45,10 @@ from ._temporal import UniformTemporalSubsample ...@@ -45,3 +45,10 @@ from ._temporal import UniformTemporalSubsample
from ._type_conversion import PILToTensor, ToImagePIL, ToImageTensor, ToPILImage from ._type_conversion import PILToTensor, ToImagePIL, ToImageTensor, ToPILImage
from ._deprecated import ToTensor # usort: skip from ._deprecated import ToTensor # usort: skip
from torchvision import _BETA_TRANSFORMS_WARNING, _WARN_ABOUT_BETA_TRANSFORMS
if _WARN_ABOUT_BETA_TRANSFORMS:
import warnings
warnings.warn(_BETA_TRANSFORMS_WARNING)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment