nvidia.dali.fn.roi_random_crop#

nvidia.dali.fn.roi_random_crop(
__input=None,
/,
*,
crop_shape,
roi_start,
bytes_per_sample_hint=[0],
in_shape=None,
preserve=False,
roi_end=None,
roi_shape=None,
seed=-1,
device=None,
name=None,
)#

Produces a fixed shape cropping window, randomly placed so that as much of the provided region of interest (ROI) is contained in it.

If the ROI is bigger than the cropping window, the cropping window will be a subwindow of the ROI. If the ROI is smaller than the cropping window, the whole ROI shall be contained in the cropping window.

If an input shape (in_shape) is given, the resulting cropping window is selected to be within the bounds of that input shape. Alternatively, the input data subject to cropping can be passed to the operator, in the operator. When providing an input shape, the region of interest should be within the bounds of the input and the cropping window shape should not be larger than the input shape.

If no input shape is provided, the resulting cropping window is unbounded, potentially resulting in out of bounds cropping.

The cropping window dimensions should be explicitly provided (crop_shape), and the ROI should be either specified with roi_start/roi_end or roi_start/roi_shape.

The operator produces an output representing the cropping window start coordinates.

Supported backends
  • ‘cpu’

Parameters:

__input (TensorList, optional) – Input to the operator.

Keyword Arguments:
  • crop_shape (int or list of int or TensorList of int) – Cropping window dimensions.

  • roi_start (int or list of int or TensorList of int) – ROI start coordinates.

  • 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.

  • in_shape (int or list of int or TensorList of int, optional) –

    Shape of the input data.

    If provided, the cropping window start will be selected so that the cropping window is within the bounds of the input.

    Note

    Providing in_shape is incompatible with feeding the input data directly as a positional input.

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

  • roi_end (int or list of int or TensorList of int, optional) –

    ROI end coordinates.

    Note

    Using roi_end is mutually exclusive with roi_shape.

  • roi_shape (int or list of int or TensorList of int, optional) –

    ROI shape.

    Note

    Using roi_shape is mutually exclusive with roi_end.

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

    Random seed.

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