OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[Py OV] Fix issue with passing (h, w) sequence to PreprocessConverter.Resize (#26687)
Alicja Miloszewskabc29a580a108
diff --git a/src/bindings/python/src/openvino/preprocess/torchvision/torchvision_preprocessing.py b/src/bindings/python/src/openvino/preprocess/torchvision/torchvision_preprocessing.pyindex af0f5bb24b3..f8b51afd546 100644--- a/src/bindings/python/src/openvino/preprocess/torchvision/torchvision_preprocessing.py+++ b/src/bindings/python/src/openvino/preprocess/torchvision/torchvision_preprocessing.py@@ -294,12 +294,13 @@ class _(TransformConverterBase):target_h, target_w = _setup_size(transform.size, "Incorrect size type for Resize operation")- # rescale the smaller image edge- current_h, current_w = meta["image_dimensions"]- if current_h > current_w:- target_h = int(transform.size * (current_h / current_w))- elif current_w > current_h:- target_w = int(transform.size * (current_w / current_h))+ if isinstance(transform.size, int):+ # rescale the smaller image edge+ current_h, current_w = meta["image_dimensions"]+ if current_h > current_w:+ target_h = int(transform.size * (current_h / current_w))+ elif current_w > current_h:+ target_w = int(transform.size * (current_w / current_h))ppp.input(input_idx).tensor().set_layout(Layout("NCHW"))diff --git a/tests/layer_tests/py_frontend_tests/test_torchvision_preprocessor.py b/tests/layer_tests/py_frontend_tests/test_torchvision_preprocessor.pyindex bfaa782ab59..78bd4d526dd 100644--- a/tests/layer_tests/py_frontend_tests/test_torchvision_preprocessor.py+++ b/tests/layer_tests/py_frontend_tests/test_torchvision_preprocessor.py@@ -87,21 +87,27 @@ def test_normalize():reason="Ticket: 114816",)@pytest.mark.parametrize(- ("target_size", "interpolation", "tolerance"),+ ("target_size", "current_size", "interpolation", "tolerance"),[- ((220, 220, 3), transforms.InterpolationMode.NEAREST, 4e-05),- ((200, 240, 3), transforms.InterpolationMode.NEAREST, 0.3), # Ticket 127670- ((220, 220, 3), transforms.InterpolationMode.BILINEAR, 4e-03),- ((200, 240, 3), transforms.InterpolationMode.BILINEAR, 4e-03),- ((220, 220, 3), transforms.InterpolationMode.BICUBIC, 4e-03),- ((200, 240, 3), transforms.InterpolationMode.BICUBIC, 4e-03),+ (224, (220, 220, 3), transforms.InterpolationMode.NEAREST, 4e-05),+ (224, (200, 240, 3), transforms.InterpolationMode.NEAREST, 0.3), # Ticket 127670+ (224, (220, 220, 3), transforms.InterpolationMode.BILINEAR, 4e-03),+ (224, (200, 240, 3), transforms.InterpolationMode.BILINEAR, 4e-03),+ (224, (220, 220, 3), transforms.InterpolationMode.BICUBIC, 4e-03),+ (224, (200, 240, 3), transforms.InterpolationMode.BICUBIC, 4e-03),+ ((224, 224), (220, 220, 3), transforms.InterpolationMode.NEAREST, 4e-05),+ ((224, 224), (200, 240, 3), transforms.InterpolationMode.NEAREST, 4e-05),+ ((224, 224), (220, 220, 3), transforms.InterpolationMode.BILINEAR, 4e-03),+ ((224, 224), (200, 240, 3), transforms.InterpolationMode.BILINEAR, 4e-03),+ ((224, 224), (220, 220, 3), transforms.InterpolationMode.BICUBIC, 4e-03),+ ((224, 224), (200, 240, 3), transforms.InterpolationMode.BICUBIC, 4e-03),],)-def test_resize(target_size, interpolation, tolerance):- test_input = np.random.randint(255, size=target_size, dtype=np.uint8)+def test_resize(target_size, current_size, interpolation, tolerance):+ test_input = np.random.randint(255, size=current_size, dtype=np.uint8)preprocess_pipeline = transforms.Compose([- transforms.Resize(224, interpolation=interpolation),+ transforms.Resize(target_size, interpolation=interpolation),transforms.ToTensor(),],)