Skip to content

Commit 2f3a43f

Browse files
authored
[Cherry-pick for 0.21] Fix doc of masks_to_boxes (#8798) (#8799)
1 parent b411ffc commit 2f3a43f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

torchvision/ops/boxes.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,13 @@ def masks_to_boxes(masks: torch.Tensor) -> torch.Tensor:
404404
Compute the bounding boxes around the provided masks.
405405
406406
Returns a [N, 4] tensor containing bounding boxes. The boxes are in ``(x1, y1, x2, y2)`` format with
407-
``0 <= x1 < x2`` and ``0 <= y1 < y2``.
407+
``0 <= x1 <= x2`` and ``0 <= y1 <= y2``.
408+
409+
.. warning::
410+
411+
In most cases the output will guarantee ``x1 < x2`` and ``y1 < y2``. But
412+
if the input is degenerate, e.g. if a mask is a single row or a single
413+
column, then the output may have x1 = x2 or y1 = y2.
408414
409415
Args:
410416
masks (Tensor[N, H, W]): masks to transform where N is the number of masks

0 commit comments

Comments
 (0)