Shortcuts

masks_to_boxes

torchvision.ops.masks_to_boxes(masks: Tensor) Tensor[source]

计算提供的掩码周围的边界框。

返回一个包含边界框的[N, 4]张量。这些框的格式为(x1, y1, x2, y2),其中 0 <= x1 < x20 <= y1 < y2

Parameters:

masks (Tensor[N, H, W]) – 要转换的掩码,其中N是掩码的数量,而(H, W)是空间维度。

Returns:

边界框

Return type:

张量[N, 4]

使用 masks_to_boxes 的示例:

将口罩重新利用为边界框

Repurposing masks into bounding boxes