habana_frameworks.mediapipe.fn.ImageDecoder

Class:
  • habana_frameworks.mediapipe.fn.ImageDecoder(**kwargs)

Define graph call:
  • __call__(input, random_crop_tensor)

Parameter:
  • input - Input to decoder (image file list or buffer list).

  • (optional) random_crop_tensor - Tensor containing crop coordinates of each image in a batch, size=[4, batch_size]. Supported dimensions: minimum = 2, maximum = 2. Supported data types: FLOAT32.

Description:

Decodes and resizes batch of images. Supported formats: JPEG. Random crop of decoded images can be done by providing random crop input tensor or by providing random_crop_type along with scale_min, scale_max, ratio_max, ratio_min arguments.

Supported backend:
  • HPU

Keyword Arguments:

kwargs

Description

output_format

Output image format produced by decoder.

  • Type: habana_frameworks.mediapipe.media_types.imgtype

  • Default: RGB_I

  • Optional: yes

  • Supported types:

    • RGB_I (interleaved)

    • RGB_P (planar)

resize

Image resizing dimension after decoding in width, height.

  • Type: list[int]

  • Default: [0, 0]

  • Optional: No

resampling_mode

Resampling mode selection.

  • Type: habana_frameworks.mediapipe.media_types.ftype

  • Default: BI_LINEAR

  • Optional: yes

  • Supported types:

    • LINEAR

    • LANCZOS

    • NEAREST

    • BI_LINEAR

    • BICUBIC

    • SPLINE

    • BOX

random_crop_type

Random crop mode selection.

  • Type: habana_frameworks.mediapipe.media_types.randomCropType

  • Default: NO_RANDOM_CROP

  • Optional: yes

  • Supported types:

    • NO_RANDOM_CROP

    • RANDOMIZED_AREA_AND_ASPECT_RATIO_CROP

    • CENTER_CROP.

seed

Seed value used for calculation of random crop window for RANDOMIZED_AREA_AND_ASPECT_RATIO_CROP.

  • Type: int

  • Default: 0

  • Optional: yes

scale_min

Specifies the lower bounds for the random area of the crop before resizing. The scale is defined with respect to the area of the original image.

  • Type: float

  • Default: 0.0

  • Optional: yes (for RANDOMIZED_AREA_AND_ASPECT_RATIO_CROP)

scale_max

Specifies the upper bounds for the random area of the crop before resizing. The scale is defined with respect to the area of the original image.

  • Type: float

  • Default: 0.0

  • Optional: yes (for RANDOMIZED_AREA_AND_ASPECT_RATIO_CROP)

ratio_min

Specifies ratio lower bounds for the random aspect ratio of the crop before resizing.

  • Type: float

  • Default: 0.0

  • Optional: yes (for RANDOMIZED_AREA_AND_ASPECT_RATIO_CROP)

ratio_max

Specifies ratio upper bounds for the random aspect ratio of the crop before resizing.

  • Type: float

  • Default: 0.0

  • Optional: yes (for RANDOMIZED_AREA_AND_ASPECT_RATIO_CROP)

Note

  1. Performance considerations:

    • Maximal performance is achieved when image scale factor is up to 9x.

    • Cropping to less than 48x48 pixels results in performance degradation.

  2. RANDOMIZED_AREA_AND_ASPECT_RATIO_CROP algorithm needs scale_min, scale_max, ratio_min and ratio_max for calculating target area and aspect ratio to decide crop window.

RANDOMIZED_AREA_AND_ASPECT_RATIO_CROP Details:

Go to the following link and then Class RandomResizedCrop -> get_params() https://pytorch.org/vision/stable/_modules/torchvision/transforms/transforms.html#RandomCrop.forward