Skip to content

Commit 25e44e7

Browse files
authored
Import CPP refactor from POC (#302)
Initial import from POC Contains: Detection, instance segmentation, semantic segmentation Support for sync and batch Removed async from public api Tiling support for detection
1 parent 83e2c06 commit 25e44e7

File tree

140 files changed

+2474
-8910
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+2474
-8910
lines changed

.github/workflows/test_accuracy.yml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,8 @@ jobs:
4242
mkdir build && cd build
4343
pip install nanobind==2.4.0
4444
pip install typing_extensions==4.12.2
45-
cmake ../tests/cpp/accuracy/
45+
cmake ../tests/cpp
4646
make -j
47-
- name: Build CPP-PY Bindings
48-
run: |
49-
source venv/bin/activate
50-
pip install src/cpp/py_bindings
5147
- name: Run CPP Test
5248
run: |
5349
build/test_accuracy -d data -p tests/python/accuracy/public_scope.json
54-
- name: Run CPP-PY Bindings Test
55-
run: |
56-
source venv/bin/activate
57-
pip list
58-
pytest --data=./data --config=./tests/python/accuracy/public_scope.json tests/cpp/accuracy/test_bindings.py

.github/workflows/test_precommit.yml

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -47,81 +47,6 @@ jobs:
4747
github_token: ${{ secrets.GITHUB_TOKEN}}
4848
# missingInclude: cppcheck can't find stl, openvino, opencv
4949
other_options: --suppress=missingInclude -Isrc/cpp/models/include -Isrc/cpp/utils/include -Isrc/cpp/pipelines/include --check-config
50-
CPP-Precommit:
51-
runs-on: ubuntu-22.04
52-
steps:
53-
- uses: actions/checkout@v3
54-
- uses: actions/setup-python@v4
55-
with:
56-
python-version: "3.10"
57-
cache: pip
58-
- name: Create and start a virtual environment
59-
run: |
60-
python -m venv venv
61-
source venv/bin/activate
62-
- name: Install dependencies
63-
run: |
64-
source venv/bin/activate
65-
python -m pip install --upgrade pip
66-
pip install src/python/[tests,build] --extra-index-url https://download.pytorch.org/whl/cpu
67-
68-
sudo bash src/cpp/install_dependencies.sh
69-
- name: Prepare test data
70-
run: |
71-
source venv/bin/activate
72-
python tests/cpp/precommit/prepare_data.py -d data -p tests/cpp/precommit/public_scope.json
73-
- name: Build
74-
run: |
75-
mkdir build && cd build
76-
pip install nanobind==2.4.0
77-
pip install typing_extensions==4.12.2
78-
cmake ../tests/cpp/precommit/
79-
cmake --build . -j $((`nproc`*2+2))
80-
- name: Run test
81-
run: |
82-
build/test_sanity -d data -p tests/cpp/precommit/public_scope.json && build/test_model_config -d data
83-
CPP-Windows-Precommit:
84-
runs-on: windows-latest
85-
steps:
86-
- uses: actions/checkout@v3
87-
- uses: actions/setup-python@v4
88-
with:
89-
python-version: 3.9
90-
cache: pip
91-
- name: Create and start a virtual environment
92-
shell: bash
93-
run: |
94-
python -m venv venv
95-
source venv/Scripts/activate
96-
- name: Install dependencies
97-
shell: bash
98-
run: |
99-
source venv/Scripts/activate
100-
python -m pip install --upgrade pip
101-
pip install src/python/[tests,build] --extra-index-url https://download.pytorch.org/whl/cpu
102-
curl https://storage.openvinotoolkit.org/repositories/openvino/packages/2024.6/windows/w_openvino_toolkit_windows_2024.6.0.17404.4c0f47d2335_x86_64.zip --output w_openvino_toolkit_windows.zip
103-
unzip w_openvino_toolkit_windows.zip
104-
rm w_openvino_toolkit_windows.zip
105-
curl -L https://github.com/opencv/opencv/releases/download/4.10.0/opencv-4.10.0-windows.exe --output opencv-4.10.0-windows.exe
106-
./opencv-4.10.0-windows.exe -oopencv -y
107-
rm opencv-4.10.0-windows.exe
108-
- name: Prepare test data
109-
shell: bash
110-
run: |
111-
source venv/Scripts/activate
112-
python tests/cpp/precommit/prepare_data.py -d data -p tests/cpp/precommit/public_scope.json
113-
- name: Build
114-
shell: bash
115-
run: |
116-
mkdir build && cd build
117-
MSYS_NO_PATHCONV=1 cmake ../examples/cpp/ -DOpenVINO_DIR=$GITHUB_WORKSPACE/w_openvino_toolkit_windows_2024.6.0.17404.4c0f47d2335_x86_64/runtime/cmake -DOpenCV_DIR=$GITHUB_WORKSPACE/opencv/opencv/build -DCMAKE_CXX_FLAGS=/WX
118-
cmake --build . --config Release -j $((`nproc`*2+2))
119-
- name: Run sync sample
120-
shell: cmd
121-
# .\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
122-
run: |
123-
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\otx_models\detection_model_with_xai_head.xml .\data\BloodImage_00007.jpg
12550
serving_api:
12651
strategy:
12752
fail-fast: false

examples/cpp/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,5 +94,4 @@ find_package(OpenCV REQUIRED COMPONENTS imgcodecs)
9494

9595
add_subdirectory(../../src/cpp ${Samples_BINARY_DIR}/src/cpp)
9696

97-
add_example(NAME asynchronous_api SOURCES ./asynchronous_api/main.cpp DEPENDENCIES model_api)
98-
add_example(NAME synchronous_api SOURCES ./synchronous_api/main.cpp DEPENDENCIES model_api)
97+
add_example(NAME synchronous_api SOURCES ./main.cpp DEPENDENCIES model_api)
File renamed without changes.

examples/cpp/asynchronous_api/README.md

Lines changed: 0 additions & 55 deletions
This file was deleted.

examples/cpp/asynchronous_api/main.cpp

Lines changed: 0 additions & 88 deletions
This file was deleted.

examples/cpp/synchronous_api/main.cpp renamed to examples/cpp/main.cpp

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

6-
#include <models/detection_model.h>
7-
#include <models/input_data.h>
8-
#include <models/results.h>
96
#include <stddef.h>
7+
#include <tasks/detection.h>
8+
#include <tasks/results.h>
109

1110
#include <cstdint>
1211
#include <exception>
@@ -31,13 +30,13 @@ int main(int argc, char* argv[]) try {
3130
}
3231

3332
// Instantiate Object Detection model
34-
auto model = DetectionModel::create_model(argv[1]); // works with SSD models. Download it using Python Model API
33+
auto model = DetectionModel::load(argv[1], {}); // works with SSD models. Download it using Python Model API
3534

3635
// Run the inference
37-
auto result = model->infer(image);
36+
auto result = model.infer(image);
3837

3938
// Process detections
40-
for (auto& obj : result->objects) {
39+
for (auto& obj : result.objects) {
4140
std::cout << " " << std::left << std::setw(9) << obj.label << " | " << std::setw(10) << obj.confidence << " | "
4241
<< std::setw(4) << int(obj.x) << " | " << std::setw(4) << int(obj.y) << " | " << std::setw(4)
4342
<< int(obj.x + obj.width) << " | " << std::setw(4) << int(obj.y + obj.height) << "\n";

examples/python/asynchronous_api/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python3
22
#
3-
# Copyright (C) 2020-2024 Intel Corporation
3+
# Copyright (C) 2020-2025 Intel Corporation
44
# SPDX-License-Identifier: Apache-2.0
55
#
66

examples/python/serving_api/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python3
22
#
3-
# Copyright (C) 2020-2024 Intel Corporation
3+
# Copyright (C) 2020-2025 Intel Corporation
44
# SPDX-License-Identifier: Apache-2.0
55
#
66

examples/python/synchronous_api/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python3
22
#
3-
# Copyright (C) 2020-2024 Intel Corporation
3+
# Copyright (C) 2020-2025 Intel Corporation
44
# SPDX-License-Identifier: Apache-2.0
55
#
66

0 commit comments

Comments
 (0)