datumaro.plugins.openvino_plugin.samples.utils#

Functions

create_bboxes_with_rescaling(bboxes, labels, ...)

gen_hash_key(features)

rescale_img_keeping_aspect_ratio(img, ...[, ...])

Rescale image while maintaining its aspect ratio.

Classes

RescaledImage(image, scale)

Dataclass for a rescaled image.

datumaro.plugins.openvino_plugin.samples.utils.gen_hash_key(features: ndarray) HashKey[source]#
datumaro.plugins.openvino_plugin.samples.utils.create_bboxes_with_rescaling(bboxes: ndarray, labels: ndarray, r_scale: float) List[Bbox][source]#
class datumaro.plugins.openvino_plugin.samples.utils.RescaledImage(image: ndarray, scale: float)[source]#

Bases: object

Dataclass for a rescaled image.

This dataclass represents a rescaled image along with the scaling information.

image#

The rescaled image as a NumPy array.

Type:

numpy.ndarray

scale#

The scale factor by which the image was resized to fit the model input size. The scale factor is the same for both height and width.

Type:

float

Note

The image attribute stores the rescaled image as a NumPy array. The scale attribute represents the scale factor used to resize the image. The scale factor indicates how much the image was scaled to fit the model’s input size.

image: ndarray#
scale: float#
datumaro.plugins.openvino_plugin.samples.utils.rescale_img_keeping_aspect_ratio(img: ndarray, h_model: int, w_model: int, padding: bool = True) RescaledImage[source]#

Rescale image while maintaining its aspect ratio.

This function rescales the input image to fit the requirements of the model input. It also attempts to preserve the original aspect ratio of the input image. If the aspect ratio of the input image does not match the aspect ratio required by the model, the function applies zero padding to the image boundaries to maintain the aspect ratio if padding option is true.

Parameters:
  • img – The image to be rescaled.

  • h_model – The desired height of the image required by the model.

  • w_model – The desired width of the image required by the model.

  • padding – If true, pad the output image boundaries to make the output image size (h_model, w_model). Otherwise, there is no pad, so that the output image size can be different with `(h_model, w_model).