Skip to content

Commit 0e2f3cb

Browse files
committed
Merge remote-tracking branch 'origin/master' into vs/bindings_tests
2 parents 6d2de0c + c3d5445 commit 0e2f3cb

File tree

18 files changed

+76
-141
lines changed

18 files changed

+76
-141
lines changed

.github/workflows/test_accuracy.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,19 @@ jobs:
3434
run: |
3535
source venv/bin/activate
3636
pytest --data=./data tests/python/accuracy/test_accuracy.py
37-
# DATA=data pytest --data=./data tests/python/accuracy/test_YOLOv8.py # checkpoints are not available sometimes
3837
- name: Install CPP dependencies
3938
run: |
4039
sudo bash src/cpp/install_dependencies.sh
4140
- name: Build CPP Test
4241
run: |
43-
source venv/bin/activate
42+
mkdir build && cd build
4443
pip install nanobind==2.4.0
4544
pip install typing_extensions==4.12.2
46-
mkdir build && cd build
47-
cmake ../tests/cpp/accuracy/ -DPython_ROOT_DIR=$(python -c "import sys; print(sys.prefix)")
45+
cmake ../tests/cpp/accuracy/
4846
make -j
4947
- name: Run CPP Test
5048
run: |
5149
build/test_accuracy -d data -p tests/python/accuracy/public_scope.json
52-
# DATA=data build/test_YOLOv8 # checkpoints are not available sometimes
5350
- name: Run CPP-PY Bindings Test
5451
run: |
5552
source venv/bin/activate

.github/workflows/test_precommit.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ jobs:
121121
# .\w_openvino_toolkit_windows_2023.0.0.10926.b4452d56304_x86_64\setupvars.bat exits with 0 code without moving to a next command. Set PATH manually
122122
run: |
123123
set PATH=opencv\opencv\build\x64\vc16\bin;w_openvino_toolkit_windows_2024.6.0.17404.4c0f47d2335_x86_64\runtime\bin\intel64\Release;w_openvino_toolkit_windows_2024.6.0.17404.4c0f47d2335_x86_64\runtime\3rdparty\tbb\bin;%PATH%
124-
.\build\Release\synchronous_api.exe .\data\public\ssd_mobilenet_v1_fpn_coco\FP16\ssd_mobilenet_v1_fpn_coco.xml .\data\BloodImage_00007.jpg
124+
.\build\Release\synchronous_api.exe .\data\otx_models\detection_model_with_xai_head.xml .\data\BloodImage_00007.jpg
125125
serving_api:
126126
strategy:
127127
fail-fast: false
@@ -147,7 +147,7 @@ jobs:
147147
run: |
148148
python -m pip install --upgrade pip
149149
python -m pip install src/python/[ovms,tests]
150-
python -c "from model_api.models import DetectionModel; DetectionModel.create_model('ssd_mobilenet_v1_fpn_coco').save('ovms_models/ssd_mobilenet_v1_fpn_coco/1/ssd_mobilenet_v1_fpn_coco.xml')"
151-
docker run -d --rm -v $GITHUB_WORKSPACE/ovms_models/:/models -p 8000:8000 openvino/model_server:latest --model_path /models/ssd_mobilenet_v1_fpn_coco/ --model_name ssd_mobilenet_v1_fpn_coco --rest_port 8000 --log_level DEBUG --target_device CPU
152150
python tests/cpp/precommit/prepare_data.py -d data -p tests/cpp/precommit/public_scope.json
151+
python -c "from model_api.models import DetectionModel; DetectionModel.create_model('./data/otx_models/detection_model_with_xai_head.xml').save('ovms_models/ssd_mobilenet_v1_fpn_coco/1/ssd_mobilenet_v1_fpn_coco.xml')"
152+
docker run -d --rm -v $GITHUB_WORKSPACE/ovms_models/:/models -p 8000:8000 openvino/model_server:latest --model_path /models/ssd_mobilenet_v1_fpn_coco/ --model_name ssd_mobilenet_v1_fpn_coco --rest_port 8000 --log_level DEBUG --target_device CPU
153153
python examples/python/serving_api/run.py data/coco128/images/train2017/000000000009.jpg # detects 4 objects

src/cpp/CMakeLists.txt

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,8 @@ endif()
3333

3434
find_package(OpenCV REQUIRED COMPONENTS core imgproc)
3535

36-
# Looking for OpenVINO in the python distribution. It doesn't work for cross-compiling build
37-
if(NOT CMAKE_CROSSCOMPILING)
38-
set(Python_FIND_VIRTUALENV FIRST)
39-
find_package(Python COMPONENTS Interpreter Development REQUIRED)
40-
execute_process(
41-
COMMAND ${Python_EXECUTABLE} -c "from openvino.utils import get_cmake_path; print(get_cmake_path(), end='')"
42-
OUTPUT_VARIABLE OpenVINO_DIR_PY
43-
ERROR_QUIET
44-
)
45-
endif()
46-
4736
find_package(OpenVINO REQUIRED
48-
COMPONENTS Runtime Threading
49-
HINTS "${OpenVINO_DIR_PY}")
37+
COMPONENTS Runtime Threading)
5038

5139
include(FetchContent)
5240
FetchContent_Declare(json URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz)

src/cpp/install_dependencies.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PU
55

66
apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
77

8-
echo "deb https://apt.repos.intel.com/openvino/2024 ubuntu22 main" | sudo tee /etc/apt/sources.list.d/intel-openvino-2024.list
8+
echo "deb https://apt.repos.intel.com/openvino/2025 ubuntu22 main" | sudo tee /etc/apt/sources.list.d/intel-openvino-2025.list
99

1010
apt update
1111

1212
#Install OpenCV
1313
apt-get install libopencv-dev
1414

1515
# Install OpenVINO
16-
apt install openvino
16+
sudo apt install openvino-2025.0.0

src/python/model_api/adapters/openvino_adapter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (C) 2020-2024 Intel Corporation
2+
# Copyright (C) 2020-2025 Intel Corporation
33
# SPDX-License-Identifier: Apache-2.0
44
#
55

@@ -15,7 +15,7 @@
1515
from numpy import ndarray
1616

1717
try:
18-
import openvino.runtime as ov
18+
import openvino as ov
1919
from openvino import (
2020
AsyncInferQueue,
2121
Core,

src/python/model_api/adapters/utils.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (C) 2020-2024 Intel Corporation
2+
# Copyright (C) 2020-2025 Intel Corporation
33
# SPDX-License-Identifier: Apache-2.0
44
#
55

@@ -11,10 +11,9 @@
1111

1212
import cv2
1313
import numpy as np
14-
from openvino import Model, OVAny, Type, layout_helpers
15-
from openvino.runtime import Input, Node, Output
16-
from openvino.runtime import opset10 as opset
17-
from openvino.runtime.utils.decorators import custom_preprocess_function
14+
from openvino import Input, Model, Node, Output, OVAny, Type, layout_helpers
15+
from openvino import opset10 as opset
16+
from openvino.utils.decorators import custom_preprocess_function
1817

1918
if TYPE_CHECKING:
2019
from collections.abc import Callable

src/python/model_api/models/classification.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (C) 2020-2024 Intel Corporation
2+
# Copyright (C) 2020-2025 Intel Corporation
33
# SPDX-License-Identifier: Apache-2.0
44
#
55

@@ -12,9 +12,9 @@
1212
from typing import TYPE_CHECKING
1313

1414
import numpy as np
15+
from openvino import Model, Type
16+
from openvino import opset10 as opset
1517
from openvino.preprocess import PrePostProcessor
16-
from openvino.runtime import Model, Type
17-
from openvino.runtime import opset10 as opset
1818

1919
from model_api.models.image_model import ImageModel
2020
from model_api.models.result import ClassificationResult, Label

src/python/model_api/visualizer/visualizer.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
# Copyright (C) 2024 Intel Corporation
44
# SPDX-License-Identifier: Apache-2.0
55

6-
from pathlib import Path
7-
from typing import Union
6+
from __future__ import annotations # TODO: remove when Python3.9 support is dropped
87

8+
from typing import TYPE_CHECKING
9+
10+
import numpy as np
911
from PIL import Image
1012

1113
from model_api.models.result import (
@@ -18,7 +20,6 @@
1820
Result,
1921
)
2022

21-
from .layout import Layout
2223
from .scene import (
2324
AnomalyScene,
2425
ClassificationScene,
@@ -29,18 +30,27 @@
2930
SegmentationScene,
3031
)
3132

33+
if TYPE_CHECKING:
34+
from pathlib import Path
35+
36+
from .layout import Layout
37+
3238

3339
class Visualizer:
3440
"""Utility class to automatically select the correct scene and render/show it."""
3541

36-
def __init__(self, layout: Union[Layout, None] = None) -> None:
42+
def __init__(self, layout: Layout | None = None) -> None:
3743
self.layout = layout
3844

39-
def show(self, image: Image, result: Result) -> Image:
45+
def show(self, image: Image | np.ndarray, result: Result) -> None:
46+
if isinstance(image, np.ndarray):
47+
image = Image.fromarray(image)
4048
scene = self._scene_from_result(image, result)
4149
return scene.show()
4250

43-
def save(self, image: Image, result: Result, path: Path) -> None:
51+
def save(self, image: Image | np.ndarray, result: Result, path: Path) -> None:
52+
if isinstance(image, np.ndarray):
53+
image = Image.fromarray(image)
4454
scene = self._scene_from_result(image, result)
4555
scene.save(path)
4656

src/python/pyproject.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (C) 2024 Intel Corporation
2+
# Copyright (C) 2024-2025 Intel Corporation
33
# SPDX-License-Identifier: Apache-2.0
44
#
55

@@ -27,8 +27,7 @@ dependencies = [
2727
"numpy>=1.16.6",
2828
"opencv-python",
2929
"scipy>=1.5.4",
30-
"openvino>=2024.0",
31-
"openvino-dev>=2024.0",
30+
"openvino>=2025.0",
3231
"omz_tools @ git+https://github.com/openvinotoolkit/open_model_zoo.git@master#egg=omz_tools&subdirectory=tools/model_tools",
3332
"pillow",
3433
]
@@ -42,7 +41,6 @@ tests = [
4241
"httpx",
4342
"pytest",
4443
"pytest-mock",
45-
"openvino-dev[onnx,pytorch,tensorflow2]",
4644
"ultralytics>=8.0.114,<=8.0.205",
4745
"onnx",
4846
"onnxruntime",

tests/cpp/accuracy/CMakeLists.txt

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,7 @@ include(../cmake/common.cmake)
6565

6666
find_package(OpenCV REQUIRED COMPONENTS core highgui videoio imgproc imgcodecs)
6767

68-
set(Python_FIND_VIRTUALENV FIRST)
69-
find_package(Python REQUIRED)
70-
execute_process(
71-
COMMAND ${Python_EXECUTABLE} -c "from openvino.utils import get_cmake_path; print(get_cmake_path(), end='')"
72-
OUTPUT_VARIABLE OpenVINO_DIR_PY
73-
ERROR_QUIET
74-
)
75-
find_package(OpenVINO REQUIRED
76-
COMPONENTS Runtime Threading
77-
HINTS "${OpenVINO_DIR_PY}")
78-
68+
set(ENABLE_PY_BINDINGS OFF)
7969
add_subdirectory(../../../src/cpp ${tests_BINARY_DIR}/model_api/cpp)
8070

8171
add_test(NAME test_accuracy SOURCES test_accuracy.cpp DEPENDENCIES model_api)

0 commit comments

Comments
 (0)