Utils#
- class model_api.adapters.utils.InputTransform(reverse_input_channels=False, mean_values=None, scale_values=None)#
Bases:
object- __call__(inputs)#
Call self as a function.
- class model_api.adapters.utils.Layout(layout='')#
Bases:
object- static from_openvino(input)#
Create Layout from openvino input
- static from_shape(shape)#
Create Layout from given shape
- Return type:
str
- static from_user_layouts(input_names, user_layouts)#
Create Layout for input based on user info
- static parse_layouts(layout_string)#
Parse layout parameter in format “input0:NCHW,input1:NC” or “NCHW” (applied to all inputs)
- Return type:
dict|None
- model_api.adapters.utils.change_layout(image, layout)#
Changes the input image layout to fit the layout of the model input layer.
- Parameters:
image (ndarray) – a single image as 3D array in HWC layout
layout (str) – target layout
- Returns:
the image with layout aligned with the model layout
- Return type:
ndarray
- model_api.adapters.utils.crop_resize(size, interpolation, pad_value)#
- Return type:
Callable
- model_api.adapters.utils.crop_resize_graph(input, size)#
- Return type:
Node
- model_api.adapters.utils.crop_resize_ocv(image, size)#
- Return type:
ndarray
- model_api.adapters.utils.get_rt_info_from_dict(rt_info_dict, path)#
- Return type:
OVAny
- model_api.adapters.utils.load_parameters_from_onnx(onnx_model)#
- Return type:
dict[str,Any]
- model_api.adapters.utils.resize_image(size, interpolation, pad_value)#
- Return type:
Callable
- model_api.adapters.utils.resize_image_graph(input, size, keep_aspect_ratio, interpolation, pad_value)#
- Return type:
Node
- model_api.adapters.utils.resize_image_letterbox(size, interpolation, pad_value)#
- Return type:
Callable
- model_api.adapters.utils.resize_image_letterbox_graph(input, size, interpolation, pad_value)#
- Return type:
Node
- model_api.adapters.utils.resize_image_letterbox_ocv(image, size, interpolation=1, pad_value=0)#
- Return type:
ndarray
- model_api.adapters.utils.resize_image_ocv(image, size, keep_aspect_ratio=False, is_pad=False, pad_value=0, interpolation=1)#
- Return type:
ndarray
- model_api.adapters.utils.resize_image_with_aspect(size, interpolation, pad_value)#
- Return type:
Callable
- model_api.adapters.utils.resize_image_with_aspect_ocv(image, size, interpolation=1)#
- Return type:
ndarray
- model_api.adapters.utils.setup_python_preprocessing_pipeline(layout, resize_mode, interpolation_mode, target_shape, pad_value, dtype=<class 'int'>, brg2rgb=False, mean=None, scale=None, input_idx=0)#
Sets up a Python preprocessing pipeline for model adapters.
- Parameters:
layout (
str) – Target layout for the input (e.g., “NCHW”, “NHWC”)resize_mode (
str) – Type of resizing (“crop”, “standard”, “fit_to_window”, “fit_to_window_letterbox”)interpolation_mode (
str) – Interpolation method (“LINEAR”, “CUBIC”, “NEAREST”)target_shape (
tuple[int,...]) – Target shape for resizingpad_value (
int) – Padding value for letterbox resizingdtype (
type) – Data type for preprocessingbrg2rgb (
bool) – Whether to convert BGR to RGBmean (
Optional[list[Any]]) – Mean values for normalizationscale (
Optional[list[Any]]) – Scale values for normalizationinput_idx (
int) – Input index (unused but kept for compatibility)
- Returns:
A preprocessing function that can be applied to input data
- Return type:
Callable