SanitizeBoundingBoxes — Torchvision 0.22 documentation (original) (raw)

class torchvision.transforms.v2.SanitizeBoundingBoxes(min_size: float = 1.0, min_area: float = 1.0, labels_getter: Optional[Union[Callable[[Any], Any], str]] = 'default')[source]

Remove degenerate/invalid bounding boxes and their corresponding labels and masks.

This transform removes bounding boxes and their associated labels/masks that:

It can also sanitize other tensors like the “iscrowd” or “area” properties from COCO (see labels_getter parameter).

It is recommended to call it at the end of a pipeline, before passing the input to the models. It is critical to call this transform ifRandomIoUCrop was called. If you want to be extra careful, you may call it after all transforms that may modify bounding boxes but once at the end should be enough in most cases.

Parameters:

Examples using SanitizeBoundingBoxes:

forward(*inputs: Any) → Any[source]

Do not override this! Use transform() instead.

transform(inpt: Any, params: Dict[str, Any]) → Any[source]

Method to override for custom transforms.

See How to write your own v2 transforms