RandomIoUCrop — Torchvision 0.22 documentation (original) (raw)

class torchvision.transforms.v2.RandomIoUCrop(min_scale: float = 0.3, max_scale: float = 1.0, min_aspect_ratio: float = 0.5, max_aspect_ratio: float = 2.0, sampler_options: Optional[List[float]] = None, trials: int = 40)[source]

Random IoU crop transformation from“SSD: Single Shot MultiBox Detector”.

This transformation requires an image or video data and tv_tensors.BoundingBoxes in the input.

Warning

In order to properly remove the bounding boxes below the IoU threshold, RandomIoUCropmust be followed by SanitizeBoundingBoxes, either immediately after or later in the transforms pipeline.

If the input is a torch.Tensor or a TVTensor (e.g. Image,Video, BoundingBoxes etc.) it can have arbitrary number of leading batch dimensions. For example, the image can have [..., C, H, W] shape. A bounding box can have [..., 4] shape.

Parameters:

Examples using RandomIoUCrop:

make_params(flat_inputs: List[Any]) → Dict[str, Any][source]

Method to override for custom transforms.

See How to write your own v2 transforms

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

Method to override for custom transforms.

See How to write your own v2 transforms