From ab748ab9291616ff60dbda256e82e389b6eec325 Mon Sep 17 00:00:00 2001 From: Nicolas Hug Date: Thu, 12 Dec 2024 12:51:53 +0000 Subject: [PATCH] Fix doc of masks_to_boxes (#8798) --- 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