From 2f3a43fbca2070ca6f0a863e7e92fcd750eb0c1a Mon Sep 17 00:00:00 2001 From: Nicolas Hug Date: Thu, 12 Dec 2024 13:01:17 +0000 Subject: [PATCH] [Cherry-pick for 0.21] Fix doc of masks_to_boxes (#8798) (#8799) --- torchvision/ops/boxes.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/torchvision/ops/boxes.py b/torchvision/ops/boxes.py index 309990ea03a..96631278d48 100644 --- a/torchvision/ops/boxes.py +++ b/torchvision/ops/boxes.py @@ -404,7 +404,13 @@ def masks_to_boxes(masks: torch.Tensor) -> torch.Tensor: Compute the bounding boxes around the provided masks. Returns a [N, 4] tensor containing bounding boxes. The boxes are in ``(x1, y1, x2, y2)`` format with - ``0 <= x1 < x2`` and ``0 <= y1 < y2``. + ``0 <= x1 <= x2`` and ``0 <= y1 <= y2``. + + .. warning:: + + In most cases the output will guarantee ``x1 < x2`` and ``y1 < y2``. But + if the input is degenerate, e.g. if a mask is a single row or a single + column, then the output may have x1 = x2 or y1 = y2. Args: masks (Tensor[N, H, W]): masks to transform where N is the number of masks