CropMirrorNormalize

class dragon.vm.dali.ops.CropMirrorNormalize(
  crop=None,
  mirror=None,
  mean=0.0,
  std=1.0,
  dtype='float32',
  output_layout='NCHW',
  **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 values to normalize input
    mean=(102., 115., 122.),
    std=(1., 1., 1.),
    # Or ``float16`` for fp16 training
    dtype='float32',
    # Or ``NHWC``
    output_layout='NCHW'
)
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='NCHW',
  **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 ({'float16', 'float32'}, optional) – The data type of output.
  • output_layout ({'NCHW', 'NHWC'}, optional) – The data format of output.
Returns:

nvidia.dali.ops.CropMirrorNormalize – The operator.