- 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)¶
[BETA] Random IoU crop transformation from “SSD: Single Shot MultiBox Detector”.
The RandomIoUCrop transform is in Beta stage, and while we do not expect major breaking changes, some APIs may still change according to user feedback. Please submit any feedback you may have in this issue: https://github.com/pytorch/vision/issues/6753, and you can also check out https://github.com/pytorch/vision/issues/7319 to learn more about the APIs that we suspect might involve future changes.
This transformation requires an image or video data and
datapoints.BoundingBoxin the input.
In order to properly remove the bounding boxes below the IoU threshold, RandomIoUCrop must be followed by
SanitizeBoundingBox, either immediately after or later in the transforms pipeline.
If the input is a
BoundingBoxetc.) it can have arbitrary number of leading batch dimensions. For example, the image can have
[..., C, H, W]shape. A bounding box can have
min_scale (float, optional) – Minimum factors to scale the input size.
max_scale (float, optional) – Maximum factors to scale the input size.
min_aspect_ratio (float, optional) – Minimum aspect ratio for the cropped image or video.
max_aspect_ratio (float, optional) – Maximum aspect ratio for the cropped image or video.
sampler_options (list of python:float, optional) – List of minimal IoU (Jaccard) overlap between all the boxes and a cropped image or video. Default,
Nonewhich corresponds to
[0.0, 0.1, 0.3, 0.5, 0.7, 0.9, 1.0]
trials (int, optional) – Number of trials to find a crop for a given value of minimal IoU (Jaccard) overlap. Default, 40.
RandomIoUCrop:Transforms v2: End-to-end object detection example