Pre-Processing Transform YAML References
  • 21 Dec 2022
  • 5 Minutes to read
  • Dark
    Light
  • PDF

Pre-Processing Transform YAML References

  • Dark
    Light
  • PDF

Article summary

The sections in this article are the available pre-processing transforms.

BinarizeLabelValues

  • Type:Object
  • Category: Labels only
  • Description: Transforms the labels to have only 1 and 0 values. If image labels are a list (in a multi-label case) then the behavior is to binarize with [] and [1]. For bboxes_labels, all of them will be converted to 0, since there's no "background" bounding box.
  • Properties:
    • always_apply:
      • Type: Boolean
      • Default: False
    • p:
      • Type: Number
      • Default: 1.0
      • Minimum: 0
      • Maximum: 1

Blur

  • Type: Object
  • Category: Pixel level
  • Description: Blur the input image using a random size kernel.
  • Properties:
    • lower limit:
      • Type: integer
      • Default: 3
      • Minimum: 3
      • Maximum: 100
    • upper_limit:
      • Type: integer
      • Default: 7
      • Minimum: 5
      • Maximum: 100
    • always_apply:
      • Type: Boolean
      • Default: False
    • p:
      • Type: Number
      • Default: 0.5
      • Minimum: 0
      • Maximum: 1

Cast

  • Type: Object
  • Category: Others 
  • Description: Casts a given set of keys to the desired type.
  • Properties:
    • image:
      • Type: string
      • Default: uint8
      • Enum: ['bool', 'uint8', 'uint16', 'int8', 'uint32', 'int16', 'int32', 'int64', 'float32', 'float64']
    • label:
      • Type: String
      • Default: Int32
      • Enum: ['bool', 'uint8', 'uint16', 'int8', 'uint32', 'int16', 'int32', 'int64', 'float32', 'float64']
    • mask:
      • Type: String
      • Default: Int32
      • Enum: ['bool', 'uint8', 'uint16', 'int8', 'uint32', 'int16', 'int32', 'int64', 'float32', 'float64']
    • bboxes:
      • Type: string
      • Default: int32
      • Enum: ['bool', 'uint8', 'uint16', 'int8', 'uint32', 'int16', 'int32', 'int64', 'float32', 'float64']
    • bboxes_labels:
      • Type: string
      • Default: int32
      • Enum: ['bool', 'uint8', 'uint16', 'int8', 'uint32', 'int16', 'int32', 'int64', 'float32', 'float64']
    • always_apply:
      • Type: Boolean
      • Default: False
    • p:
      • Type: Number
      • Default: 1.0
      • Minimum: 0
      • Maximum: 1

ClassnameToIndex

  • Type: Object
  • Category: Labels only
  • Description: Transform the string labels to indices by applying a mapping between class names and class indices.
  • Properties:
    • label_map:
      • Type: Object
    • always_apply:
      • Type: boolean
      • Default: False
    • p:
      • Type: Number
      • Default: 1.0
      • Minimum: 0
      • Maximum: 1

Compose

  • Type: Object
  • Category: Compose
  • Description: Compose a sequence of transforms.
  • Properties:
    • transforms:
      • Type: Array
      • Items:
        • Type: Object
    • bbox_params:
      • anyOf:
        • Type: Null
        • Type: Object
    • keypoint_params:
      • anyOf:
        • Type: Null
        • Type: Object
    • additional_targets:
      • anyOf:
        • Type: Null
        • Type: Object
    • p:
      • Type: Number
      • Default: 1.0
      • Minimum: 0
      • Maximum: 1

ConvertColor

  • Type: Object 
  • Category: Pixel level
  • Description: Converts an image to another color space.
  • Properties
    • color_mode:
      • Type: String
      • Default: None
      • Enum: ['RGB2GRAY', 'RGB2HSV', 'GRAY2RGB', 'RGB2LAB', 'RGB2BGR', 'RGBA2RGB']
    • always_apply:
      • Type: Boolean
      • Default: False
    • p:
      • Type: Number
      • Default: 1.0
      • Minimum: 0
      • Maximum: 1

Crop

  • Type: Object
  • Category: Spatial level
  • Description: Crop a rectangular region from an image.
  • Properties:
    • x_min:
      • Type: Integer
      • Default: None
      • Minimum: 0
    • y_min:
      • Type: Integer
      • Default: None
      • Minimum: 0
    • x_max:
      • Type: Integer
      • Default: None 
      • Minimum: 0
    • y_max:
      • Type: Integer
      • Default: None
      • Minimum: 0
    • always_apply:
      • Type: Boolean
      • Default: False
    • p:
      • Type: Number
      • Default: 1.0
      • Minimum: 0
      • Maximum: 1

Downscale

  • Type: Object
  • Category: Pixel level
  • Description: Decreases image quality by downscaling and upscaling
  • Properties:
    • always_apply:
      • Type: boolean
      • Default: False
    • p:
      • Type: number
      • Default: 0.5
      • Minimum: 0
      • Maximum: 1

ExpandBoxes

  • Type: Object 
  • Category: Labels only
  • Description: Changes the size of the bounding box while attempting to keep the object centered.
  • Properties:
    • height_delta:
      • Type: integer
      • Default: None
      • Minimum: 0
    • width_delta:
      • Type: integer
      • Default: None
      • Minimum: 0
    • always_apply:
      • Type: boolean
      • Default: False
    • p:
      • Type: number
      • Default: 1.0
      • Minimum: 0
      • Maximum: 1

ExpandBoxesTo

  • Type: Object 
  • Category: Labels only 
  • Description: Changes the shape of the bounding box to a predefined width and height while attempting to keep the object centered.
  • Properties:
    • height:
      • Type: Integer
      • Default: None
      • Minimum: 0
    • width:
      • Type: Integer
      • Default: None
      • Minimum: 0
    • always_apply:
      • Type: Boolean
      • Default: False
    • p:
      • Type: number
      • Default: 1.0
      • Minimum: 0
      • Maximum: 1

ExpandBoxesToFit

  • Type: Object
  • Category: Labels only
  • Description: Preprocessing transforms to expand bounding boxes with extreme ratios (height/width and width/height), or smaller than a minimum size so that it is easier to fit them with anchors in an Object Detection task.
  • Properties:
    • min_size:
      • Type: Integer
      • Default: None
      • Minimum: 0
    • max_aspect_ratio:
      • Type: Number
      • Default: 6
      • Minimum: 0
    • always_apply:
      • Type: Boolean
      • Default: False
    • p:
      • Type: Number
      • Default: 1.0
      • Minimum: 0
      • Maximum: 1

GaussianBlur

  • Type: Object
  • Category: Pixel level
  • Description: Blur the input image using a Gaussian filter with a random kernel size.
  • Properties:
    • lower_limit:
      • Type: Integer
      • Default: 3
      • Minimum: 3
      • Maximum: 100
    • upper_limit:
      • Type: Integer
      • Default: 7
      • Minimum: 5
      • Maximum: 100
    • p:
      • Type: Number
      • Default: 0.5
      • Minimum: 0
      • Maximum: 1

HorizontalFlip

  • Type: Object
  • Category: Spatial level
  • Description: Flips the input horizontally
  • Properties:
    • p:
      • Type: Number
      • Default: 0.5
      • Minimum: 0
      • Maximum: 1

HueSaturationValue

  • Type: Object
  • Category: Pixel level
  • Description: Randomly changes the hue, saturation, and value of the input image.
  • Properties
    • hue_shift_lower_limit:
      • Type: Integer
      • Default: -20
      • Minimum: -255
      • Maximum: 255
    • hue_shift_upper_limit:
      • Type: Integer
      • Default: 20
      • Minimum: -255
      • Maximum: 255
    • sat_shift_lower_limit:
      • Type: Integer
      • Default: -30
      • Minimum: -255
      • Maximum: 255
    • sat_shift_upper_limit:
      • Type: Integer
      • Default: 30
      • Minimum: -25
      • Maximum: 255
    • val_shift_lower_limit:
      • Type: Integer
      • Default: -20
      • Minimum: -255
      • Maximum: 255
    • val_shift_upper_limit:
      • Type: Integer
      • Default: 20
      • Minimum: -255
      • Maximum: 255
    • p:
      • Type: Number
      • Default: 0.5
      • Minimum: 0
      • Maximum: 1

IgnoreLabelValues

  • Type: Object
  • Category: Labels only
  • Description: Transforms the labels to ignore some values. For masks, the ignored values change to zero. For bounding boxes, they are removed. For image labels, lists are removed and single values change to zero.
  • Properties:
    • to_ignore:
      • Type: Array
      • Items:
        • Type: Integer
        • Minimum: 1
    • always_apply:
      • Type: Boolean
      • Default: False
    • p:
      • Type: Number
      • Default: 1.0
      • Minimum: 0
      • Maximum: 1

IndexToClassname

  • Type: Object
  • Category: Labels only 
  • Description: Transform the int labels to strings by applying a mapping between class indices and class names.
  • Properties:
    • label_map:
      • Type: Object
    • always_apply:
      • Type: Boolean
      • Default: False
    • p:
      • Type: Number
      • Default: 1.0
      • Minimum: 0
      • Maximum: 1

MotionBlur

  • Type: Object 
  • Category: Pixel level
  • Description: Apply motion blur to the input image using a randomly-sized kernel.
  • Properties:
    •  lower_limit:
      • Type: Integer
      • Default: 3
      • Minimum: 3
      • Maximum: 100
    • upper_limit:
      • Type: Integer
      • Default: 7
      • Minimum: 5
      • Maximum: 100
    • p:
      • Type: Number
      • Default: 0.5
      • Minimum: 0
      • Maximum: 1

Normalize

  • Type: Object 
  • Category: Pixel level
  • Description: Divide pixel values by 255, subtract the mean per channel, then divide by std per channel. Images must be in RGB format.
  • Properties:
    • mean:
      • Type: array
      • Default: (0.485, 0.456, 0.406)
        • Items:
          • Type: Number
          • ExclusiveMinimum: 0
          • ExclusiveMaximum: 1
    • std:
      • Type: Array
      • Default: (0.229, 0.224, 0.225)
        • Items:
          • Type: Number
          • ExclusiveMinimum: 0
          • ExclusiveMaximum: 1
    • always_apply:
      • Type: Boolean
      • Default: False
    • p:
      • Type: Number
      • Default: 1.0
      • Minimum: 0
      • Maximum: 1

NormalizeRange

  • Type: Object
  • Category: Pixel level
  • Description: Normalizes the image so its values go from being in the range input_range to the range output_range. For example, if the input_range is [0, 255] you can convert the image to the range [-1, 1].
  • Properties:
    • output_range:
      • Type: Array
        • Items:
          • Type: Number
    • input_range:
      • Type: Array
      • Default: (0, 255)
      • Items:
        • Type: Number
    • always_apply:
      • Type: Boolean
      • Default: False
    • p:
      • Type: Number
      • Default: 1.0
      • Minimum: 0
      • Maximum: 1

OneHot

  • Type: Object
  • Category: Labels only
  • Description: Transform the labels to a one-hot representation.
  • Properties:
    • depth:
      • Type: Integer
      • Default: None
      • Minimum: 1
    • always_apply:
      • Type: Boolean
      • Default: False
    • p:
      • Type: Number
      • Default: 1.0
      • Minimum: 0

        Maximum: 1

OneOf

  • Type: Object
  • Category: Compose
  • Description: Select one of the transforms to apply. Probabilities will be weights.
  • Properties:
    • transforms:
      • Type: Array
      • Items:
        • Type: Object
    • p:
      • Type: Number
      • Default: 1.0
      • Minimum: 0
      • Maximum: 1

RandAugment

  • Type: Object
  • Category: Pixel level
  • Description: This transform implements the data augmentation policy from this paper. In summary, there are 12 available augmentations: [Identity, Equalize, Rotate, Solarize, Posterize, RandomContrast, RandomBrightness, GaussianBlur, ShearX, ShearY, TranslateX, TranslateY]. Out of this list, every time that the transform is applied, a set of number_transforms is chosen, e.g. [Posterize, TranslateY], and these transforms are applied with magnitude magnitude.
    • Example:

      >>> transform = tr.RandAugment(number_transforms=2, magnitude=13)
      >>> transformed = transform(image=image, bboxes=bboxes, bboxes_labels=bboxes_labels, mask=mask)

  • Properties:
    • number_transforms:
      • Type: Integer
      • Default: 2
      • Minimum: 1
      • Maximum: 12
    • magnitude:
      • Type: Number
      • Default: 4
      • Minimum: 0
      • Maximum: 10
    • always_apply:
      • Type: Boolean
      • Default: False
    • p:
      • Type: Number
      • Default: 1.0
      • Minimum: 0
      • Maximum: 1

RandomBrightness

  • Type: Object
  • Category: Pixel level
  • Description: Randomly changes the brightness of the input image.
  • Properties:
    • lower_limit:
      • Type: Number
      • Default: -0.2
      • Minimum: -1
      • Maximum: 1
    • upper_limit:
      • Type: Number
      • Default: 0.2
      • Minimum: -1
      • Maximum: 1
    • always_apply:
      • Type: Boolean
      • Default: False
    • p:
      • Type: Number
      • Default: 0.5
      • Minimum: 0
      • Maximum: 1

RandomBrightnessContrast

  • Type: Object
  • Category: Pixel level
  • Description: Randomly changes the brightness and contrast of the input image.
  • Properties:
    • brightness_lower_limit:
      • Type: Number
      • Default: -0.2
      • Minimum: -1
      • Maximum: 1
    • brightness_upper_limit:
      • Type: number
      • Default: 0.2
      • Minimum: -1
      • Maximum: 1
    • contrast_lower_limit:
      • Type: Number
      • Default: -0.2
      • Minimum: -1
      • Maximum: 1
    • contrast_upper_limit:
      • Type: Number
      • Default: 0.2
      • Minimum: -1
      • Maximum: 1
    • always_apply:
      • Type: Boolean
      • Default: False
    • p:
      • Type: Number
      • Default: 0.5
      • Minimum: 0 
      • Maximum: 1

RandomContrast

  • Type: Object
  • Category: Pixel level 
  • Description: Randomly changes the contrast of the input image.
  • Properties:
    • lower_limit:
      • Type: Number
      • Default: -0.2
      • Minimum: -1
      • Maximum: 1
    • upper_limit:
      • Type: Number
      • Default: 0.2
      • Minimum: -1
      • Maximum: 1
    • always_apply:
      • Type: Boolean
      • Default: False
    • p:
      • Type: Number
      • Default: 0.5
      • Minimum: 0
      • Maximum: 1

RandomCrop

  • Type: Object
  • Category: Spatial level
  • Description: Crop a random rectangle of the input image. 
  • Properties:
    • height:
      • Type: Integer
      • Default: None
      • Minimum: 0
    • width:
      • Type: Integer
      • Default: None
      • Minimum: 0
    • always_apply:
      • Type: Boolean
      • Default: False
    • p:
      • Type: Number
      • Default: 1.0
      • Minimum: 0
      • Maximum: 1

RandomRotate90

  • Type: Object
  • Category: Spatial level
  • Description: Randomly rotates the input by 90 degrees by zero or more times.
  • Properties:
    • p:
      • Type: Number
      • Default: 0.5
      • Minimum: 0
      • Maximum: 1

RandomScale

  • Type: Object
  • Category: Spatial level
  • Description: Randomly resizes the input. Output image size will be different from the input size.
  • Properties:
    • lower_limit:
      • Type: Number
      • Default: 0.9
      • Minimum: 0
      • Maximum: 2
    • upper_limit:
      • Type: Number
      • Default: 1.1
      • Minimum: 0
      • Maximum: 4
    • interpolation:
      • Type: String
      • Default: LINEAR
      • Enum: ['LINEAR', 'AREA', 'CUBIC', 'NEAREST', 'LANCZOS4']
    • always_apply:
      • Type: Boolean
      • Default: False
    • p:
      • Type: Number
      • Default: 0.5
      • Minimum: 0
      • Maximum: 1

RemapLabelValues

  • Type: Object
  • Category: Labels only
  • Description: Transforms the values of the labels and gives a mapping between current values and desired values.
  • Properties:
    • label_map:
      • Type: Object
    • always_apply:
      • Type: Boolean
      • Default: False
    • p:
      • Type: Number
      • Default: 1.0
      • Minimum: 0
      • Maximum: 1

Resize

  • Type: Object
  • Category: Spatial level
  • Description: Resize the input 
  • Properties:
    • height:
      • Type: Integer
      • Default: None
      • Minimum: 1
    • width:
      • Type: Integer
      • Default: None
      • Minimum: 1
    • always_apply:
      • Type: Boolean
      • Default: False
    • p:
      • Type: Number
      • Default: 1.0
      • Minimum: 0
      • Maximum: 1

Rotate

  • Type: Object
  • Category: Spatial level
  • Description: Rotate the input by a randomly selected angle from the uniform distribution.
  • Properties:
    • lower_limit:
      • Type: Integer
      • Default: -90
      • Minimum: -180
      • Maximum: 0
    • upper_limit:
      • Type: Integer
      • Default: 90
      • Minimum: 0
      • Maximum: 180
    • interpolation:
      • Type: String
      • Default: LINEAR
      • Enum: ['LINEAR', 'AREA', 'CUBIC', 'NEAREST', 'LANCZOS4']
    • border_mode:
      • Type: String
      • Default: REFLECT_101
      • Enum: ['CONSTANT', 'REPLICATE', 'REFLECT', 'WRAP', 'REFLECT_101']
    • always_apply:
      • Type: Boolean
      • Default: False
    • p:
      • Type: Number
      • Default: 0.5
      • Minimum: 0
      • Maximum: 1

ShiftScaleRotate

  • Type: Object
  • Category: Spatial level
  • Description: Randomly applies affine transforms: translate, scale, and rotate input.
  • Properties:
    • shift_lower_limit:
      • Type: Number
      • Default: -0.0625
      • Minimum: -1
      • Maximum: 0
    • shift_upper_limit:
      • Type: Number
      • Default: 0.0625
      • Minimum: 0
      • Maximum: 1
    • scale_lower_limit:
      • Type: Number
      • Default: -0.1
      • Maximum: 0
    • scale_upper_limit:
      • Type: Number
      • Default: 0.1
      • Minimum: 0
    • rotate_lower_limit:
      • Type: Integer
      • Default: -45
      • Minimum: -360
      • Maximum: 0
    • rotate_upper_limit:
      • Type: Integer
      • Default: 45
      • Minimum: 0
      • Maximum: 360
    • interpolation:
      • Type: String
      • Default: LINEAR
      • Enum: ['LINEAR', 'AREA', 'CUBIC', 'NEAREST', 'LANCZOS4']
    • border_mode:
      • Type: String
      • Default: CONSTANT
      • Enum: ['CONSTANT', 'REPLICATE', 'REFLECT', 'WRAP', 'REFLECT_101']
    • always_apply:
      • Type: Boolean
      • Default: False
    • p:
      • Type: Number
      • Default: 0.5
      • Minimum: 0
      • Maximum: 1

VerticalFlip

  • Type: Object
  • Category: Spatial level
  • Description: Flips the input horizontally.
  • Properties:
    • p:
      • Type: Number
      • Default: 0.5
      • Minimum: 0
      • Maximum: 1

Was this article helpful?