Skip to content

Change betastatus doc warning and v2 import warning #7329

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions docs/source/beta_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,26 @@

class BetaStatus(Directive):
has_content = True
text = "The {api_name} is in Beta stage, and backward compatibility is not guaranteed."

def run(self):
api_name = " ".join(self.content)
text = f"The {api_name} is in Beta stage, and backward compatibility is not guaranteed."
text = self.text.format(api_name=" ".join(self.content))
return [nodes.warning("", nodes.paragraph("", "", nodes.Text(text)))]


class V2BetaStatus(BetaStatus):
text = (
"The {api_name} is in Beta stage, and 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 "
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not know how to create hyperlinks from here. Neither rst nor pure html worked. 😭 😭 😭 😭

"out https://github.com/pytorch/vision/issues/7319 to learn "
"more about the APIs that we suspect might involve future changes."
)


def setup(app):
app.add_directive("betastatus", BetaStatus)
app.add_directive("v2betastatus", V2BetaStatus)
return {
"version": "0.1",
"parallel_read_safe": True,
Expand Down
8 changes: 4 additions & 4 deletions docs/source/transforms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ Transforming and augmenting images
:ref:`sphx_glr_auto_examples_plot_transforms_v2_e2e.py`.
Note that these transforms are still BETA, and while we don't expect major
breaking changes in the future, some APIs may still change according to user
feedback. Please submit any feedback you may have in
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.
feedback. Please submit any feedback you may have `here
<https://github.com/pytorch/vision/issues/6753>`_, and you can also check
out `this issue <https://github.com/pytorch/vision/issues/7319>`_ to learn
more about the APIs that we suspect might involve future changes.

Transforms are common image transformations available in the
``torchvision.transforms`` module. They can be chained together using
Expand Down
9 changes: 5 additions & 4 deletions torchvision/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,11 @@ def _is_tracing():
_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."
"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_transform_warning()."
)

Expand Down
2 changes: 1 addition & 1 deletion torchvision/transforms/v2/_augment.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
class RandomErasing(_RandomApplyTransform):
"""[BETA] Randomly select a rectangle region in the input image or video and erase its pixels.

.. betastatus:: RandomErasing transform
.. v2betastatus:: RandomErasing transform

This transform does not support PIL Image.
'Random Erasing Data Augmentation' by Zhong et al. See https://arxiv.org/abs/1708.04896
Expand Down
8 changes: 4 additions & 4 deletions torchvision/transforms/v2/_auto_augment.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class AutoAugment(_AutoAugmentBase):
r"""[BETA] AutoAugment data augmentation method based on
`"AutoAugment: Learning Augmentation Strategies from Data" <https://arxiv.org/pdf/1805.09501.pdf>`_.

.. betastatus:: AutoAugment transform
.. v2betastatus:: AutoAugment transform

This transformation works on images and videos only.

Expand Down Expand Up @@ -342,7 +342,7 @@ class RandAugment(_AutoAugmentBase):
`"RandAugment: Practical automated data augmentation with a reduced search space"
<https://arxiv.org/abs/1909.13719>`_.

.. betastatus:: RandAugment transform
.. v2betastatus:: RandAugment transform

This transformation works on images and videos only.

Expand Down Expand Up @@ -425,7 +425,7 @@ class TrivialAugmentWide(_AutoAugmentBase):
r"""[BETA] Dataset-independent data-augmentation with TrivialAugment Wide, as described in
`"TrivialAugment: Tuning-free Yet State-of-the-Art Data Augmentation" <https://arxiv.org/abs/2103.10158>`_.

.. betastatus:: TrivialAugmentWide transform
.. v2betastatus:: TrivialAugmentWide transform

This transformation works on images and videos only.

Expand Down Expand Up @@ -496,7 +496,7 @@ class AugMix(_AutoAugmentBase):
r"""[BETA] AugMix data augmentation method based on
`"AugMix: A Simple Data Processing Method to Improve Robustness and Uncertainty" <https://arxiv.org/abs/1912.02781>`_.

.. betastatus:: AugMix transform
.. v2betastatus:: AugMix transform

This transformation works on images and videos only.

Expand Down
20 changes: 10 additions & 10 deletions torchvision/transforms/v2/_color.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
class Grayscale(Transform):
"""[BETA] Convert images or videos to grayscale.

.. betastatus:: Grayscale transform
.. v2betastatus:: Grayscale transform

If the input is a :class:`torch.Tensor`, it is expected
to have [..., 3 or 1, H, W] shape, where ... means an arbitrary number of leading dimensions
Expand Down Expand Up @@ -42,7 +42,7 @@ def _transform(self, inpt: Any, params: Dict[str, Any]) -> Any:
class RandomGrayscale(_RandomApplyTransform):
"""[BETA] Randomly convert image or videos to grayscale with a probability of p (default 0.1).

.. betastatus:: RandomGrayscale transform
.. v2betastatus:: RandomGrayscale transform

If the input is a :class:`torch.Tensor`, it is expected to have [..., 3 or 1, H, W] shape,
where ... means an arbitrary number of leading dimensions
Expand Down Expand Up @@ -76,7 +76,7 @@ def _transform(self, inpt: Any, params: Dict[str, Any]) -> Any:
class ColorJitter(Transform):
"""[BETA] Randomly change the brightness, contrast, saturation and hue of an image or video.

.. betastatus:: ColorJitter transform
.. v2betastatus:: ColorJitter transform

If the input is a :class:`torch.Tensor`, it is expected
to have [..., 1 or 3, H, W] shape, where ... means an arbitrary number of leading dimensions.
Expand Down Expand Up @@ -182,7 +182,7 @@ class RandomPhotometricDistort(Transform):
"""[BETA] Randomly distorts the image or video as used in `SSD: Single Shot
MultiBox Detector <https://arxiv.org/abs/1512.02325>`_.

.. betastatus:: RandomPhotometricDistort transform
.. v2betastatus:: RandomPhotometricDistort transform

This transform relies on :class:`~torchvision.transforms.v2.ColorJitter`
under the hood to adjust the contrast, saturation, hue, brightness, and also
Expand Down Expand Up @@ -282,7 +282,7 @@ def _transform(
class RandomEqualize(_RandomApplyTransform):
"""[BETA] Equalize the histogram of the given image or video with a given probability.

.. betastatus:: RandomEqualize transform
.. v2betastatus:: RandomEqualize transform

If the input is a :class:`torch.Tensor`, it is expected
to have [..., 1 or 3, H, W] shape, where ... means an arbitrary number of leading dimensions.
Expand All @@ -301,7 +301,7 @@ def _transform(self, inpt: Any, params: Dict[str, Any]) -> Any:
class RandomInvert(_RandomApplyTransform):
"""[BETA] Inverts the colors of the given image or video with a given probability.

.. betastatus:: RandomInvert transform
.. v2betastatus:: RandomInvert transform

If img is a Tensor, it is expected to be in [..., 1 or 3, H, W] format,
where ... means it can have an arbitrary number of leading dimensions.
Expand All @@ -321,7 +321,7 @@ class RandomPosterize(_RandomApplyTransform):
"""[BETA] Posterize the image or video with a given probability by reducing the
number of bits for each color channel.

.. betastatus:: RandomPosterize transform
.. v2betastatus:: RandomPosterize transform

If the input is a :class:`torch.Tensor`, it should be of type torch.uint8,
and it is expected to have [..., 1 or 3, H, W] shape, where ... means an arbitrary number of leading dimensions.
Expand All @@ -346,7 +346,7 @@ class RandomSolarize(_RandomApplyTransform):
"""[BETA] Solarize the image or video with a given probability by inverting all pixel
values above a threshold.

.. betastatus:: RandomSolarize transform
.. v2betastatus:: RandomSolarize transform

If img is a Tensor, it is expected to be in [..., 1 or 3, H, W] format,
where ... means it can have an arbitrary number of leading dimensions.
Expand All @@ -370,7 +370,7 @@ def _transform(self, inpt: Any, params: Dict[str, Any]) -> Any:
class RandomAutocontrast(_RandomApplyTransform):
"""[BETA] Autocontrast the pixels of the given image or video with a given probability.

.. betastatus:: RandomAutocontrast transform
.. v2betastatus:: RandomAutocontrast transform

If the input is a :class:`torch.Tensor`, it is expected
to have [..., 1 or 3, H, W] shape, where ... means an arbitrary number of leading dimensions.
Expand All @@ -389,7 +389,7 @@ def _transform(self, inpt: Any, params: Dict[str, Any]) -> Any:
class RandomAdjustSharpness(_RandomApplyTransform):
"""[BETA] Adjust the sharpness of the image or video with a given probability.

.. betastatus:: RandomAdjustSharpness transform
.. v2betastatus:: RandomAdjustSharpness transform

If the input is a :class:`torch.Tensor`,
it is expected to have [..., 1 or 3, H, W] shape, where ... means an arbitrary number of leading dimensions.
Expand Down
8 changes: 4 additions & 4 deletions torchvision/transforms/v2/_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class Compose(Transform):
"""[BETA] Composes several transforms together.

.. betastatus:: Compose transform
.. v2betastatus:: Compose transform

This transform does not support torchscript.
Please, see the note below.
Expand Down Expand Up @@ -61,7 +61,7 @@ def extra_repr(self) -> str:
class RandomApply(Transform):
"""[BETA] Apply randomly a list of transformations with a given probability.

.. betastatus:: RandomApply transform
.. v2betastatus:: RandomApply transform

.. note::
In order to script the transformation, please use ``torch.nn.ModuleList`` as input instead of list/tuple of
Expand Down Expand Up @@ -116,7 +116,7 @@ def extra_repr(self) -> str:
class RandomChoice(Transform):
"""[BETA] Apply single transformation randomly picked from a list.

.. betastatus:: RandomChoice transform
.. v2betastatus:: RandomChoice transform

This transform does not support torchscript.

Expand Down Expand Up @@ -155,7 +155,7 @@ def forward(self, *inputs: Any) -> Any:
class RandomOrder(Transform):
"""[BETA] Apply a list of transformations in a random order.

.. betastatus:: RandomOrder transform
.. v2betastatus:: RandomOrder transform

This transform does not support torchscript.

Expand Down
2 changes: 1 addition & 1 deletion torchvision/transforms/v2/_deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class ToTensor(Transform):
"""[BETA] Convert a PIL Image or ndarray to tensor and scale the values accordingly.

.. betastatus:: ToTensor transform
.. v2betastatus:: ToTensor transform

.. warning::
:class:`v2.ToTensor` is deprecated and will be removed in a future release.
Expand Down
Loading