datumaro.plugins.openvino_plugin.samples.utils#
Functions
|
|
|
|
|
Rescale image while maintaining its aspect ratio. |
Classes
|
Dataclass for a rescaled image. |
- 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:
- 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:
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.
- 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).