5
5
# This source code is licensed under the BSD-style license found in the
6
6
# LICENSE file in the root directory of this source tree.
7
7
8
- set -exu
8
+ set -ex
9
9
# shellcheck source=/dev/null
10
10
source " $( dirname " ${BASH_SOURCE[0]} " ) /utils.sh"
11
11
@@ -65,11 +65,33 @@ if [[ -z "${MODE:-}" ]]; then
65
65
exit 1
66
66
fi
67
67
68
+ if [[ -z " ${PYTHON_EXECUTABLE:- } " ]]; then
69
+ PYTHON_EXECUTABLE=python3
70
+ fi
71
+
68
72
TARGET_LIBS=" "
69
73
70
74
if [[ " ${MODE} " =~ .* openvino.* ]]; then
71
75
OPENVINO=ON
72
76
TARGET_LIBS=" $TARGET_LIBS openvino_backend "
77
+
78
+ git clone https://github.com/daniil-lyakhov/openvino.git
79
+
80
+ cd openvino && git checkout dl/executorch/yolo12
81
+ git submodule update --init --recursive
82
+ sudo ./install_build_dependencies.sh
83
+ mkdir build && cd build
84
+ cmake .. -DCMAKE_BUILD_TYPE=Release -DENABLE_PYTHON=ON
85
+ make -j$( nproc)
86
+
87
+ cd ..
88
+ cmake --install build --prefix dist
89
+
90
+ cd openvino
91
+ source dist/setupvars.sh
92
+ cd ../backends/openvino
93
+ pip install -r requirements.txt
94
+ cd ../../
73
95
else
74
96
OPENVINO=OFF
75
97
fi
@@ -81,51 +103,70 @@ else
81
103
XNNPACK=OFF
82
104
fi
83
105
84
- if [[ -z " ${PYTHON_EXECUTABLE:- } " ]]; then
85
- PYTHON_EXECUTABLE=python3
86
- fi
87
-
88
106
which " ${PYTHON_EXECUTABLE} "
89
107
108
+
109
+ DIR=" examples/models/yolo12"
110
+ $PYTHON_EXECUTABLE -m pip install -r ${DIR} /requirements.txt
111
+
90
112
cmake_install_executorch_libraries () {
91
- echo " Installing libexecutorch.a, libextension_module.so, libportable_ops_lib.a"
92
113
rm -rf cmake-out
93
- mkdir cmake-out
94
-
95
- retry cmake \
96
- -DCMAKE_INSTALL_PREFIX=cmake-out \
97
- -DEXECUTORCH_BUILD_OPENVINO=" $OPENVINO " \
98
- -DEXECUTORCH_BUILD_XNNPACK=" $XNNPACK " \
99
- -DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
100
- -DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
101
- -DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \
102
- -DEXECUTORCH_ENABLE_LOGGING=ON \
103
- -DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
104
- -DEXECUTORCH_BUILD_PYBIND=ON \
105
- -Bcmake-out
106
- cmake --build cmake-out -j9 --target install --config " $CMAKE_BUILD_TYPE "
114
+ build_dir=cmake-out
115
+ mkdir $build_dir
116
+
117
+
118
+ retry cmake -DCMAKE_INSTALL_PREFIX=" ${build_dir} " \
119
+ -DCMAKE_BUILD_TYPE=" ${CMAKE_BUILD_TYPE} " \
120
+ -DEXECUTORCH_BUILD_OPENVINO=" $OPENVINO " \
121
+ -DEXECUTORCH_BUILD_XNNPACK=" $XNNPACK " \
122
+ -DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
123
+ -DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
124
+ -DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \
125
+ -DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
126
+ -B" ${build_dir} "
127
+
128
+ # Build the project
129
+ cmake --build ${build_dir} --target install --config ${CMAKE_BUILD_TYPE} -j$( nproc)
130
+
131
+ export CMAKE_ARGS="
132
+ -DEXECUTORCH_BUILD_OPENVINO=" $OPENVINO " \
133
+ -DEXECUTORCH_BUILD_XNNPACK=" $XNNPACK " \
134
+ -DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
135
+ -DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
136
+ -DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \
137
+ -DEXECUTORCH_ENABLE_LOGGING=ON \
138
+ -DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
139
+ -DEXECUTORCH_BUILD_PYBIND=ON"
140
+
141
+ echo $TARGET_LIBS
142
+ export CMAKE_BUILD_ARGS=" --target $TARGET_LIBS "
143
+ pip install . --no-build-isolation
107
144
}
108
145
109
146
cmake_build_demo () {
110
147
echo " Building yolo12 runner"
111
- dir=" examples/models/yolo12"
112
148
retry cmake \
113
149
-DCMAKE_BUILD_TYPE=" $CMAKE_BUILD_TYPE " \
114
150
-DUSE_OPENVINO_BACKEND=" $OPENVINO " \
115
- -DUSE_OPENVINO_BACKEND =" $XNNPACK " \
116
- -Bcmake-out/${dir } \
117
- ${dir }
118
- cmake --build cmake-out/${dir } -j9 --config " $CMAKE_BUILD_TYPE "
151
+ -DUSE_XNNPACK_BACKEND =" $XNNPACK " \
152
+ -Bcmake-out/${DIR } \
153
+ ${DIR }
154
+ cmake --build cmake-out/${DIR } -j9 --config " $CMAKE_BUILD_TYPE "
119
155
120
156
}
121
157
122
158
cleanup_files () {
123
- true
159
+ rm $EXPORTED_MODEL_NAME
124
160
}
125
161
126
162
prepare_artifacts_upload () {
127
163
if [ -n " ${UPLOAD_DIR} " ]; then
128
- true
164
+ echo " Preparing for uploading generated artifacs"
165
+ zip -j model.zip " ${EXPORTED_MODEL_NAME} "
166
+ mkdir -p " ${UPLOAD_DIR} "
167
+ mv model.zip " ${UPLOAD_DIR} "
168
+ mv result.txt " ${UPLOAD_DIR} "
169
+
129
170
fi
130
171
}
131
172
@@ -141,14 +182,14 @@ cmake_install_executorch_libraries
141
182
$PYTHON_EXECUTABLE -m examples.models.yolo12.export_and_validate ${EXPORT_ARGS}
142
183
143
184
144
- RUNTIME_ARGS=" --model_path=${EXPORTED_MODEL_NAME} --input_path=${INPUT_VIDEO } "
185
+ RUNTIME_ARGS=" --model_path=${EXPORTED_MODEL_NAME} --input_path=${VIDEO_PATH } "
145
186
# Check build tool.
146
187
cmake_build_demo
147
- # Run llama runner
188
+ # Run yolo12 runner
148
189
NOW=$( date +" %H:%M:%S" )
149
- echo " Starting to run llama runner at ${NOW} "
190
+ echo " Starting to run yolo12 runner at ${NOW} "
150
191
# shellcheck source=/dev/null
151
- cmake-out/examples/models/yolo12/Yolo12Detection ${RUNTIME_ARGS} > result.txt
192
+ cmake-out/examples/models/yolo12/Yolo12DetectionDemo ${RUNTIME_ARGS} > result.txt
152
193
NOW=$( date +" %H:%M:%S" )
153
194
echo " Finished at ${NOW} "
154
195
0 commit comments