nvidia.dali.fn.experimental.decoders.image_slice — NVIDIA DALI (original) (raw)

nvidia.dali.fn.experimental.decoders.image_slice(__data, __anchor=None, __shape=None, /, *, adjust_orientation=True, affine=True, axes=[1, 0], axis_names='WH', bytes_per_sample_hint=[0], device_memory_padding=16777216, device_memory_padding_jpeg2k=0, dtype=DALIDataType.UINT8, end=None, host_memory_padding=8388608, host_memory_padding_jpeg2k=0, hw_decoder_load=0.9, hybrid_huffman_threshold=1000000, jpeg_fancy_upsampling=False, normalized_anchor=True, normalized_shape=True, output_type=DALIImageType.RGB, preallocate_height_hint=0, preallocate_width_hint=0, preserve=False, rel_end=None, rel_shape=None, rel_start=None, shape=None, start=None, use_fast_idct=False, device=None, name=None)#

Decodes images and extracts regions of interest.

Supported formats: JPEG, JPEG 2000, TIFF, PNG, BMP, PNM, PPM, PGM, PBM, WebP.

The output of the decoder is in HWC layout.

The implementation uses NVIDIA nvImageCodec to decode images.

The slice can be specified by proving the start and end coordinates, or start coordinates and shape of the slice. Both coordinates and shapes can be provided in absolute or relative terms.

The slice arguments can be specified by the following named arguments:

  1. start: Slice start coordinates (absolute)
  2. rel_start: Slice start coordinates (relative)
  3. end: Slice end coordinates (absolute)
  4. rel_end: Slice end coordinates (relative)
  5. shape: Slice shape (absolute)
  6. rel_shape: Slice shape (relative)

The slice can be configured by providing start and end coordinates or start and shape. Relative and absolute arguments can be mixed (for example, rel_start can be used with shape) as long as start and shape or end are uniquely defined.

Alternatively, two extra positional inputs can be provided, specifying __anchor and __shape. When using positional inputs, two extra boolean arguments normalized_anchor/normalized_shapecan be used to specify the nature of the arguments provided. Using positional inputs for anchor and shape is incompatible with the named arguments specified above.

The slice arguments should provide as many dimensions as specified by the axis_names or axesarguments.

By default, the nvidia.dali.fn.decoders.image_slice() operator uses normalized coordinates and “WH” order for the slice arguments.

When possible, the operator uses the ROI decoding, reducing the decoding time and memory consumption.

Note

GPU accelerated decoding is only available for a subset of the image formats (JPEG, and JPEG2000). For other formats, a CPU based decoder is used. For JPEG, a dedicated HW decoder will be used when available.

Supported backends

Parameters:

Keyword Arguments:

normalized_anchorbool, optional, default = True

Determines whether the anchor positional input should be interpreted as normalized (range [0.0, 1.0]) or as absolute coordinates.

Note

This argument is only relevant when anchor data type is float. For integer types, the coordinates are always absolute.

normalized_shapebool, optional, default = True

Determines whether the shape positional input should be interpreted as normalized (range [0.0, 1.0]) or as absolute coordinates.

Note

This argument is only relevant when anchor data type is float. For integer types, the coordinates are always absolute.

output_typenvidia.dali.types.DALIImageType, optional, default = DALIImageType.RGB

The color space of the output image.

Note: When decoding to YCbCr, the image will be decoded to RGB and then converted to YCbCr, following the YCbCr definition from ITU-R BT.601.

preallocate_height_hintint, optional, default = 0

Image width hint.

Applies only to the mixed backend type in NVIDIA Ampere GPU architecture.

The hint is used to preallocate memory for the HW JPEG decoder.

preallocate_width_hintint, optional, default = 0

Image width hint.

Applies only to the mixed backend type in NVIDIA Ampere GPU architecture.

The hint is used to preallocate memory for the HW JPEG decoder.

preservebool, optional, default = False

Prevents the operator from being removed from the graph even if its outputs are not used.

rel_endfloat or list of float or TensorList of float, optional

End relative coordinates of the slice (range [0.0 - 1.0].

Note: Providing named arguments start, end, shape, rel_start, rel_end, rel_shapeis incompatible with providing positional inputs anchor and shape.

rel_shapefloat or list of float or TensorList of float, optional

Relative shape of the slice (range [0.0 - 1.0]).

Providing named arguments start, end, shape, rel_start, rel_end, rel_shapeis incompatible with providing positional inputs anchor and shape.

rel_startfloat or list of float or TensorList of float, optional

Start relative coordinates of the slice (range [0.0 - 1.0]).

Note: Providing named arguments start, end, shape, rel_start, rel_end, rel_shapeis incompatible with providing positional inputs anchor and shape.

shapeint or list of int or TensorList of int, optional

Shape of the slice.

Providing named arguments start, end, shape, rel_start, rel_end, rel_shapeis incompatible with providing positional inputs anchor and shape.

split_stages : bool, optional, default = False

Warning

The argument split_stages is now deprecated and its usage is discouraged.

startint or list of int or TensorList of int, optional

Start coordinates of the slice.

Note: Providing named arguments start/end or start/shape is incompatible with providing positional inputs anchor and shape.

use_chunk_allocator : bool, optional, default = False

Warning

The argument use_chunk_allocator is now deprecated and its usage is discouraged.

use_fast_idctbool, optional, default = False

Enables fast IDCT in the libjpeg-turbo based CPU decoder, used when device is set to “cpu” or when the it is set to “mixed” but the particular image can not be handled by the GPU implementation.

According to the libjpeg-turbo documentation, decompression performance is improved by up to 14% with little reduction in quality.