Skip to content

Commit c3d5445

Browse files
authored
Support OV 2025.0 (#266)
* Visualizer can accept np images * Promote OV version to 2025.0, fix related warnings * Del outdated OMZ model * Finally del openvino-dev * Update tests ref results * Limit torch version * Fix funtional tests * Update precommit data preparation * Fix serving api tests * Fix data paths in cpp precommit tests * Reduce buindings build scope * Disable yolo tests * Update OV in cpp tests * Don't use ov from python * Use global python for build * Skip old mobilenet in cpp tests * Ignore padim model * Delete dead code in workflows
1 parent f6126ba commit c3d5445

File tree

20 files changed

+78
-142
lines changed

20 files changed

+78
-142
lines changed

.github/workflows/test_accuracy.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,16 @@ 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
3837
- name: Install CPP dependencies
3938
run: |
4039
sudo bash src/cpp/install_dependencies.sh
4140
- name: Build CPP Test
4241
run: |
42+
mkdir build && cd build
4343
pip install nanobind==2.4.0
4444
pip install typing_extensions==4.12.2
45-
mkdir build && cd build
4645
cmake ../tests/cpp/accuracy/
4746
make -j
4847
- name: Run CPP Test
4948
run: |
5049
build/test_accuracy -d data -p tests/python/accuracy/public_scope.json
51-
DATA=data build/test_YOLOv8

.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 & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +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-
find_package(Python3 REQUIRED)
39-
execute_process(
40-
COMMAND ${Python3_EXECUTABLE} -c "from openvino.utils import get_cmake_path; print(get_cmake_path(), end='')"
41-
OUTPUT_VARIABLE OpenVINO_DIR_PY
42-
ERROR_QUIET
43-
)
44-
endif()
45-
4636
find_package(OpenVINO REQUIRED
47-
COMPONENTS Runtime Threading
48-
HINTS "${OpenVINO_DIR_PY}")
37+
COMPONENTS Runtime Threading)
4938

5039
include(FetchContent)
5140
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/cpp/py_bindings/CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
# SPDX-License-Identifier: Apache-2.0
33
#
44

5-
set(DEV_MODULE Development.Module)
6-
7-
find_package(Python COMPONENTS Interpreter ${DEV_MODULE} REQUIRED)
5+
set(Python_FIND_VIRTUALENV FIRST)
6+
find_package(Python COMPONENTS Interpreter Development REQUIRED)
87

98
execute_process(
109
COMMAND "${Python_EXECUTABLE}" -m nanobind --cmake_dir

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",

0 commit comments

Comments
 (0)