CropMirrorNormalize

class dragon.vm.dali.ops.CropMirrorNormalize(
  crop=None,
  mirror=None,
  mean=0.0,
  std=1.0,
  dtype='float32',
  output_layout='CHW',
  **kwargs
)[source]

Crop and normalize image with the horizontal flip.

Examples:

flip_rng = dali.ops.CoinFlip(0.5)
cmn = dali.ops.CropMirrorNormalize(
    # Match the number of spatial dims
    # (H, W) for 2d input
    # (D, H, W) for 3d input
    crop=(224, 224),
    # Historical BGR values to normalize input
    mean=(103.53, 116.28, 123.675),
    std=(57.375, 57.12, 58.395),
    # Or ``float16`` for fp16 training
    dtype='float32',
    # Or ``HWC``
    output_layout='CHW',
)
y = cmn(inputs['x'], mirror=flip_rng())

__new__

static CropMirrorNormalize.__new__(
  cls,
  crop=None,
  mirror=None,
  mean=0.0,
  std=1.0,
  dtype='float32',
  output_layout='CHW',
  **kwargs
)[source]

Create a CropMirrorNormalize operator.

Parameters:
  • crop (Sequence[int], optional) The cropped spatial dimensions for output.
  • mirror ({0, 1}, optional) Whether to apply the horizontal flip.
  • mean (Union[float, Sequence[float]], optional) The values to subtract.
  • std (Union[float, Sequence[float]], optional) The values to divide after subtraction.
  • dtype (str, optional, default='float32') The output data type.
  • output_layout (str, optional) The output data layout.
Returns:

nvidia.dali.ops.CropMirrorNormalize The operator.