mindspore.dataset.vision.BoundingBoxAugment

View Source On Gitee
class mindspore.dataset.vision.BoundingBoxAugment(transform, ratio=0.3)[source]

Apply a given image processing operation on a random selection of bounding box regions of a given image.

Parameters
  • transform (TensorOperation) – Transformation operation to be applied on random selection of bounding box regions of a given image.

  • ratio (float, optional) – Ratio of bounding boxes to apply augmentation on. Range: [0.0, 1.0]. Default: 0.3.

Raises
  • TypeError – If transform is an image processing operation in mindspore.dataset.vision .

  • TypeError – If ratio is not of type float.

  • ValueError – If ratio is not in range [0.0, 1.0].

  • RuntimeError – If given bounding box is invalid.

Supported Platforms:

CPU

Examples

>>> import mindspore.dataset as ds
>>> import mindspore.dataset.vision as vision
>>>
>>> image_folder_dataset = ds.ImageFolderDataset("/path/to/image_folder_dataset_directory")
>>> # set bounding box operation with ratio of 1 to apply rotation on all bounding boxes
>>> bbox_aug_op = vision.BoundingBoxAugment(vision.RandomRotation(90), 1)
>>> # map to apply ops
>>> image_folder_dataset = image_folder_dataset.map(operations=[bbox_aug_op],
...                                                 input_columns=["image", "bbox"],
...                                                 output_columns=["image", "bbox"])
Tutorial Examples: