Skip to content

Updated _meta.py docstrings #7320

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 5 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
2 changes: 2 additions & 0 deletions docs/source/transforms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ Miscellaneous
Lambda
v2.Lambda
v2.SanitizeBoundingBox
v2.ClampBoundingBox

.. _conversion_transforms:

Expand All @@ -212,6 +213,7 @@ Conversion
v2.ConvertImageDtype
v2.ConvertDtype
v2.ToDtype
v2.ConvertBoundingBoxFormat

Auto-Augmentation
-----------------
Expand Down
18 changes: 17 additions & 1 deletion torchvision/transforms/v2/_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@


class ConvertBoundingBoxFormat(Transform):
"""[BETA] Convert bounding box coordinates to the given ``format``, e.g. from "CXCYWH" to "XYXY".

.. betastatus:: ConvertBoundingBoxFormat transform

Args:
format (str or datapoints.BoundingBoxFormat): output bounding box format.
Possible values are defined by :class:`~torchvision.datapoints.BoundingBoxFormat` and
string values match the enums, e.g. "XYXY" or "XYWH" etc.
"""
_transformed_types = (datapoints.BoundingBox,)

def __init__(self, format: Union[str, datapoints.BoundingBoxFormat]) -> None:
Expand All @@ -22,7 +31,7 @@ def _transform(self, inpt: datapoints.BoundingBox, params: Dict[str, Any]) -> da


class ConvertDtype(Transform):
"""[BETA] Convert a tensor image/box/mask to the given ``dtype`` and scale the values accordingly
"""[BETA] Convert input image or video to the given ``dtype`` and scale the values accordingly.

.. betastatus:: ConvertDtype transform

Expand Down Expand Up @@ -63,6 +72,13 @@ def _transform(


class ClampBoundingBox(Transform):
"""[BETA] Clamp bounding boxes to their corresponding image dimensions.

The clamping is done according to the bounding boxes' ``spatial_size`` meta-data.

.. betastatus:: ClampBoundingBox transform

"""
_transformed_types = (datapoints.BoundingBox,)

def _transform(self, inpt: datapoints.BoundingBox, params: Dict[str, Any]) -> datapoints.BoundingBox:
Expand Down