快捷方式

sanitize_bounding_boxes

torchvision.transforms.v2.functional.sanitize_bounding_boxes(bounding_boxes: Tensor, format: Optional[BoundingBoxFormat] = None, canvas_size: Optional[Tuple[int, int]] = None, min_size: float = 1.0, min_area: float = 1.0) Tuple[Tensor, Tensor][原始碼]

移除退化/無效的邊界框並返回對應的索引掩碼。

這將移除以下邊界框:

  • 小於給定的 min_sizemin_area:預設情況下,這也會移除退化框,例如 X2 <= X1 的框。

  • 其任何座標位於對應影像之外。您可能希望先呼叫 clamp_bounding_boxes() 以避免不必要的移除。

建議在管道結束時呼叫它,在將輸入傳遞給模型之前。如果呼叫了 RandomIoUCrop,則呼叫此變換至關重要。如果您想額外小心,可以在所有可能修改邊界框的變換之後呼叫它,但在大多數情況下,只需在最後呼叫一次就足夠了。

引數:
  • bounding_boxes (Tensor 或 BoundingBoxes) – 要清理的邊界框。

  • format (str 或 BoundingBoxFormat, optional) – 邊界框的格式。如果 bounding_boxesBoundingBoxes 物件,則必須將其設為 None。

  • canvas_size (tuple of python:int, optional) – 邊界框的畫布大小(對應影像/影片的大小)。如果 bounding_boxesBoundingBoxes 物件,則必須將其設為 None。

  • min_size (float, optional) –

  • min_area (float, optional) –

返回值:

有效的邊界框子集,以及對應的索引掩碼。該掩碼可用於對與邊界框相關的其他張量(例如標籤)進行子集選擇。

返回型別:

out (tuple of Tensors)


© 版權所有 2017-至今, Torch 貢獻者。

使用 Sphinx 構建,主題由 Read the Docs 提供。

文件

查閱 PyTorch 的全面開發者文件

檢視文件

教程

獲取針對初學者和高階開發者的深度教程

檢視教程

資源

查詢開發資源並獲得問題的解答

檢視資源