RandomIoUCrop

class torchaug.transforms.RandomIoUCrop(min_scale=0.3, max_scale=1.0, min_aspect_ratio=0.5, max_aspect_ratio=2.0, sampler_options=None, trials=40, batch_transform=False)[source]

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

This transformation requires an image or video data and BoundingBoxes in the input, or in batch mode a batch of these (see BatchBoundingBoxes).

Warning

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

If the input is a torch.Tensor or a TATensor (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:
  • min_scale (float, optional) – Minimum factors to scale the input size. Default: 0.3

  • max_scale (float, optional) – Maximum factors to scale the input size. Default: 1.0

  • min_aspect_ratio (float, optional) – Minimum aspect ratio for the cropped image or video. Default: 0.5

  • max_aspect_ratio (float, optional) – Maximum aspect ratio for the cropped image or video. Default: 2.0

  • sampler_options (Optional[List[float]], optional) – List of minimal IoU (Jaccard) overlap between all the boxes and a cropped image or video. Default, None which corresponds to [0.0, 0.1, 0.3, 0.5, 0.7, 0.9, 1.0] Default: None

  • trials (int, optional) – Number of trials to find a crop for a given value of minimal IoU (Jaccard) overlap. Default, 40. Default: 40

  • batch_transform (bool, optional) – whether to apply the transform in batch mode. Default: False