Skip to content

Remove BETA status for v2 transforms #8111

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 6 commits into from
Nov 13, 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
10 changes: 0 additions & 10 deletions docs/source/beta_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,8 @@ def run(self):
return [self.node("", nodes.paragraph("", "", nodes.Text(text)))]


class V2BetaStatus(BetaStatus):
text = (
"The {api_name} is in Beta stage, and while we do not expect disruptive breaking changes, "
"some APIs may slightly change according to user feedback. Please submit any feedback you may have "
"in this issue: https://github.com/pytorch/vision/issues/6753."
)
node = nodes.note


def setup(app):
app.add_directive("betastatus", BetaStatus)
app.add_directive("v2betastatus", V2BetaStatus)
return {
"version": "0.1",
"parallel_read_safe": True,
Expand Down
7 changes: 0 additions & 7 deletions docs/source/transforms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,6 @@ you're already using tranforms from ``torchvision.transforms``, all you need to
do to is to update the import to ``torchvision.transforms.v2``. In terms of
output, there might be negligible differences due to implementation differences.

.. note::

The v2 transforms are still BETA, but at this point we do not expect
disruptive changes to be made to their public APIs. We're planning to make
them fully stable in version 0.17. Please submit any feedback you may have
`here <https://github.com/pytorch/vision/issues/6753>`_.

.. _transforms_perf:

Performance considerations
Expand Down
12 changes: 3 additions & 9 deletions torchvision/transforms/v2/_augment.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@


class RandomErasing(_RandomApplyTransform):
"""[BETA] Randomly select a rectangle region in the input image or video and erase its pixels.

.. v2betastatus:: RandomErasing transform
"""Randomly select a rectangle region in the input image or video and erase its pixels.

This transform does not support PIL Image.
'Random Erasing Data Augmentation' by Zhong et al. See https://arxiv.org/abs/1708.04896
Expand Down Expand Up @@ -207,9 +205,7 @@ def _mixup_label(self, label: torch.Tensor, *, lam: float) -> torch.Tensor:


class MixUp(_BaseMixUpCutMix):
"""[BETA] Apply MixUp to the provided batch of images and labels.

.. v2betastatus:: MixUp transform
"""Apply MixUp to the provided batch of images and labels.

Paper: `mixup: Beyond Empirical Risk Minimization <https://arxiv.org/abs/1710.09412>`_.

Expand Down Expand Up @@ -256,9 +252,7 @@ def _transform(self, inpt: Any, params: Dict[str, Any]) -> Any:


class CutMix(_BaseMixUpCutMix):
"""[BETA] Apply CutMix to the provided batch of images and labels.

.. v2betastatus:: CutMix transform
"""Apply CutMix to the provided batch of images and labels.

Paper: `CutMix: Regularization Strategy to Train Strong Classifiers with Localizable Features
<https://arxiv.org/abs/1905.04899>`_.
Expand Down
16 changes: 4 additions & 12 deletions torchvision/transforms/v2/_auto_augment.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,9 @@ def _apply_image_or_video_transform(


class AutoAugment(_AutoAugmentBase):
r"""[BETA] AutoAugment data augmentation method based on
r"""AutoAugment data augmentation method based on
`"AutoAugment: Learning Augmentation Strategies from Data" <https://arxiv.org/pdf/1805.09501.pdf>`_.

.. v2betastatus:: AutoAugment transform

This transformation works on images and videos only.

If the input is :class:`torch.Tensor`, it should be of type ``torch.uint8``, and it is expected
Expand Down Expand Up @@ -350,12 +348,10 @@ def forward(self, *inputs: Any) -> Any:


class RandAugment(_AutoAugmentBase):
r"""[BETA] RandAugment data augmentation method based on
r"""RandAugment data augmentation method based on
`"RandAugment: Practical automated data augmentation with a reduced search space"
<https://arxiv.org/abs/1909.13719>`_.

.. v2betastatus:: RandAugment transform

This transformation works on images and videos only.

If the input is :class:`torch.Tensor`, it should be of type ``torch.uint8``, and it is expected
Expand Down Expand Up @@ -434,11 +430,9 @@ def forward(self, *inputs: Any) -> Any:


class TrivialAugmentWide(_AutoAugmentBase):
r"""[BETA] Dataset-independent data-augmentation with TrivialAugment Wide, as described in
r"""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>`_.

.. v2betastatus:: TrivialAugmentWide transform

This transformation works on images and videos only.

If the input is :class:`torch.Tensor`, it should be of type ``torch.uint8``, and it is expected
Expand Down Expand Up @@ -505,11 +499,9 @@ def forward(self, *inputs: Any) -> Any:


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

.. v2betastatus:: AugMix transform

This transformation works on images and videos only.

If the input is :class:`torch.Tensor`, it should be of type ``torch.uint8``, and it is expected
Expand Down
45 changes: 11 additions & 34 deletions torchvision/transforms/v2/_color.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@


class Grayscale(Transform):
"""[BETA] Convert images or videos to grayscale.

.. v2betastatus:: Grayscale transform
"""Convert images or videos to grayscale.

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 All @@ -32,9 +30,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).

.. v2betastatus:: RandomGrayscale transform
"""Randomly convert image or videos to grayscale with a probability of p (default 0.1).

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 All @@ -59,9 +55,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.

.. v2betastatus:: ColorJitter transform
"""Randomly change the brightness, contrast, saturation and hue of an image or video.

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 @@ -163,10 +157,7 @@ def _transform(self, inpt: Any, params: Dict[str, Any]) -> Any:


class RandomChannelPermutation(Transform):
"""[BETA] Randomly permute the channels of an image or video

.. v2betastatus:: RandomChannelPermutation transform
"""
"""Randomly permute the channels of an image or video"""

def _get_params(self, flat_inputs: List[Any]) -> Dict[str, Any]:
num_channels, *_ = query_chw(flat_inputs)
Expand All @@ -177,11 +168,9 @@ def _transform(self, inpt: Any, params: Dict[str, Any]) -> Any:


class RandomPhotometricDistort(Transform):
"""[BETA] Randomly distorts the image or video as used in `SSD: Single Shot
"""Randomly distorts the image or video as used in `SSD: Single Shot
MultiBox Detector <https://arxiv.org/abs/1512.02325>`_.

.. v2betastatus:: RandomPhotometricDistort transform

This transform relies on :class:`~torchvision.transforms.v2.ColorJitter`
under the hood to adjust the contrast, saturation, hue, brightness, and also
randomly permutes channels.
Expand Down Expand Up @@ -249,9 +238,7 @@ def _transform(self, inpt: Any, params: Dict[str, Any]) -> Any:


class RandomEqualize(_RandomApplyTransform):
"""[BETA] Equalize the histogram of the given image or video with a given probability.

.. v2betastatus:: RandomEqualize transform
"""Equalize the histogram of the given image or video with a given probability.

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 @@ -268,9 +255,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.

.. v2betastatus:: RandomInvert transform
"""Inverts the colors of the given image or video with a given probability.

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 @@ -287,11 +272,9 @@ def _transform(self, inpt: Any, params: Dict[str, Any]) -> Any:


class RandomPosterize(_RandomApplyTransform):
"""[BETA] Posterize the image or video with a given probability by reducing the
"""Posterize the image or video with a given probability by reducing the
number of bits for each color channel.

.. 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.
If img is PIL Image, it is expected to be in mode "L" or "RGB".
Expand All @@ -312,11 +295,9 @@ def _transform(self, inpt: Any, params: Dict[str, Any]) -> Any:


class RandomSolarize(_RandomApplyTransform):
"""[BETA] Solarize the image or video with a given probability by inverting all pixel
"""Solarize the image or video with a given probability by inverting all pixel
values above a threshold.

.. 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.
If img is PIL Image, it is expected to be in mode "L" or "RGB".
Expand All @@ -342,9 +323,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.

.. v2betastatus:: RandomAutocontrast transform
"""Autocontrast the pixels of the given image or video with a given probability.

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 @@ -361,9 +340,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.

.. v2betastatus:: RandomAdjustSharpness transform
"""Adjust the sharpness of the image or video with a given probability.

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
16 changes: 4 additions & 12 deletions torchvision/transforms/v2/_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@


class Compose(Transform):
"""[BETA] Composes several transforms together.

.. v2betastatus:: Compose transform
"""Composes several transforms together.

This transform does not support torchscript.
Please, see the note below.
Expand Down Expand Up @@ -62,9 +60,7 @@ def extra_repr(self) -> str:


class RandomApply(Transform):
"""[BETA] Apply randomly a list of transformations with a given probability.

.. v2betastatus:: RandomApply transform
"""Apply randomly a list of transformations with a given probability.

.. note::
In order to script the transformation, please use ``torch.nn.ModuleList`` as input instead of list/tuple of
Expand Down Expand Up @@ -118,9 +114,7 @@ def extra_repr(self) -> str:


class RandomChoice(Transform):
"""[BETA] Apply single transformation randomly picked from a list.

.. v2betastatus:: RandomChoice transform
"""Apply single transformation randomly picked from a list.

This transform does not support torchscript.

Expand Down Expand Up @@ -157,9 +151,7 @@ def forward(self, *inputs: Any) -> Any:


class RandomOrder(Transform):
"""[BETA] Apply a list of transformations in a random order.

.. v2betastatus:: RandomOrder transform
"""Apply a list of transformations in a random order.

This transform does not support torchscript.

Expand Down
4 changes: 1 addition & 3 deletions torchvision/transforms/v2/_deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@


class ToTensor(Transform):
"""[BETA] [DEPRECATED] Use ``v2.Compose([v2.ToImage(), v2.ToDtype(torch.float32, scale=True)])`` instead.
"""[DEPRECATED] Use ``v2.Compose([v2.ToImage(), v2.ToDtype(torch.float32, scale=True)])`` instead.

Convert a PIL Image or ndarray to tensor and scale the values accordingly.

.. v2betastatus:: ToTensor transform

.. warning::
:class:`v2.ToTensor` is deprecated and will be removed in a future release.
Please use instead ``v2.Compose([v2.ToImage(), v2.ToDtype(torch.float32, scale=True)])``.
Expand Down
Loading