Core API (albumentations.core)


class albumentations.core.composition.Compose(transforms, preprocessing_transforms=[], postprocessing_transforms=[], to_tensor=None, bbox_params={}, keypoint_params={}, additional_targets={}, p=1.0)[source]

Compose transforms and handle all transformations regrading bounding boxes

  • transforms (list) – list of transformations to compose.
  • bbox_params (dict) – Parameters for bounding boxes transforms
  • keypoint_params (dict) – Parameters for keypoints transforms
  • additional_targets (dict) – Dict with keys - new target name, values - old target name. ex: {‘image2’: ‘image’}
  • p (float) – probability of applying all list of transforms. Default: 1.0.
bbox_params dictionary contains the following keys:
  • format (str): format of bounding boxes. Should be ‘coco’, ‘pascal_voc’ or ‘albumentations’. If None - don’t use bboxes. The coco format of a bounding box looks like [x_min, y_min, width, height], e.g. [97, 12, 150, 200]. The pascal_voc format of a bounding box looks like [x_min, y_min, x_max, y_max], e.g. [97, 12, 247, 212]. The albumentations format of a bounding box looks like pascal_voc, but between [0, 1], in other words: [x_min, y_min, x_max, y_max]`, e.g. [0.2, 0.3, 0.4, 0.5].

  • label_fields (list): list of fields that are joined with boxes, e.g labels.
    Should be same type as boxes.
  • min_area (float): minimum area of a bounding box. All bounding boxes whose
    visible area in pixels is less than this value will be removed. Default: 0.0.
  • min_visibility (float): minimum fraction of area for a bounding box
    to remain this box in list. Default: 0.0.
class albumentations.core.composition.OneOf(transforms, p=0.5)[source]

Select on of transforms to apply

  • transforms (list) – list of transformations to compose.
  • p (float) – probability of applying selected transform. Default: 0.5.

Transforms interface

albumentations.core.transforms_interface.to_tuple(param, low=None, bias=None)[source]

Convert input argument to min-max tuple :param param: Input value.

If value is scalar, return value would be (offset - value, offset + value). If value is tuple, return value would be value + offset (broadcasted).
  • low – Second element of tuple can be passed as optional argument
  • bias – An offset factor added to each element
class albumentations.core.transforms_interface.DualTransform(always_apply=False, p=0.5)[source]

Transform for segmentation task.

class albumentations.core.transforms_interface.ImageOnlyTransform(always_apply=False, p=0.5)[source]

Transform applied to image only.

class albumentations.core.transforms_interface.NoOp(always_apply=False, p=0.5)[source]

Does nothing