nvidia.dali.fn.random_resized_crop#

nvidia.dali.fn.random_resized_crop(__input, /, *, size, antialias=True, bytes_per_sample_hint=[0], dtype=None, interp_type=DALIInterpType.INTERP_LINEAR, mag_filter=DALIInterpType.INTERP_LINEAR, min_filter=DALIInterpType.INTERP_LINEAR, minibatch_size=32, num_attempts=10, preserve=False, random_area=[0.08, 1.0], random_aspect_ratio=[0.75, 1.333333], seed=-1, temp_buffer_hint=0, device=None, name=None)#

Performs a crop with a randomly selected area and aspect ratio and resizes it to the specified size.

Expects a three-dimensional input with samples in height, width, channels (HWC) layout.

This operator allows sequence inputs.

Supported backends
  • ‘cpu’

  • ‘gpu’

Parameters:

__input (TensorList ('HWC', 'CHW', 'FHWC', 'FCHW', 'CFHW')) – Input to the operator.

Keyword Arguments:
  • size (int or list of int) – Size of the resized image.

  • antialias (bool, optional, default = True) –

    If enabled, it applies an antialiasing filter when scaling down.

    Note

    Nearest neighbor interpolation does not support antialiasing.

  • bytes_per_sample_hint (int or list of int, optional, default = [0]) –

    Output size hint, in bytes per sample.

    If specified, the operator’s outputs residing in GPU or page-locked host memory will be preallocated to accommodate a batch of samples of this size.

  • dtype (nvidia.dali.types.DALIDataType, optional) –

    Output data type.

    Must be same as input type or float. If not set, input type is used.

  • interp_type (nvidia.dali.types.DALIInterpType or TensorList of nvidia.dali.types.DALIInterpType, optional, default = DALIInterpType.INTERP_LINEAR) –

    Type of interpolation to be used.

    Use min_filter and mag_filter to specify different filtering for downscaling and upscaling.

    Note

    Usage of INTERP_TRIANGULAR is now deprecated and it should be replaced by a combination of

    INTERP_LINEAR with antialias enabled.

  • mag_filter (nvidia.dali.types.DALIInterpType or TensorList of nvidia.dali.types.DALIInterpType, optional, default = DALIInterpType.INTERP_LINEAR) – Filter used when scaling up.

  • min_filter (nvidia.dali.types.DALIInterpType or TensorList of nvidia.dali.types.DALIInterpType, optional, default = DALIInterpType.INTERP_LINEAR) – Filter used when scaling down.

  • minibatch_size (int, optional, default = 32) – Maximum number of images that are processed in a kernel call.

  • num_attempts (int, optional, default = 10) – Maximum number of attempts used to choose random area and aspect ratio.

  • preserve (bool, optional, default = False) – Prevents the operator from being removed from the graph even if its outputs are not used.

  • random_area (float or list of float, optional, default = [0.08, 1.0]) –

    Range from which to choose random area fraction A.

    The cropped image’s area will be equal to A * original image’s area.

  • random_aspect_ratio (float or list of float, optional, default = [0.75, 1.333333]) – Range from which to choose random aspect ratio (width/height).

  • seed (int, optional, default = -1) –

    Random seed.

    If not provided, it will be populated based on the global seed of the pipeline.

  • temp_buffer_hint (int, optional, default = 0) –

    Initial size in bytes, of a temporary buffer for resampling.

    Note

    This argument is ignored for the CPU variant.