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,32 @@ 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
+ source dist/setupvars.sh
91
+ cd ../backends/openvino
92
+ pip install -r requirements.txt
93
+ cd ../../
73
94
else
74
95
OPENVINO=OFF
75
96
fi
@@ -81,51 +102,70 @@ else
81
102
XNNPACK=OFF
82
103
fi
83
104
84
- if [[ -z " ${PYTHON_EXECUTABLE:- } " ]]; then
85
- PYTHON_EXECUTABLE=python3
86
- fi
87
-
88
105
which " ${PYTHON_EXECUTABLE} "
89
106
107
+
108
+ DIR=" examples/models/yolo12"
109
+ $PYTHON_EXECUTABLE -m pip install -r ${DIR} /requirements.txt
110
+
90
111
cmake_install_executorch_libraries () {
91
- echo " Installing libexecutorch.a, libextension_module.so, libportable_ops_lib.a"
92
112
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 "
113
+ build_dir=cmake-out
114
+ mkdir $build_dir
115
+
116
+
117
+ retry cmake -DCMAKE_INSTALL_PREFIX=" ${build_dir} " \
118
+ -DCMAKE_BUILD_TYPE=" ${CMAKE_BUILD_TYPE} " \
119
+ -DEXECUTORCH_BUILD_OPENVINO=" $OPENVINO " \
120
+ -DEXECUTORCH_BUILD_XNNPACK=" $XNNPACK " \
121
+ -DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
122
+ -DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
123
+ -DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \
124
+ -DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
125
+ -B" ${build_dir} "
126
+
127
+ # Build the project
128
+ cmake --build ${build_dir} --target install --config ${CMAKE_BUILD_TYPE} -j$( nproc)
129
+
130
+ export CMAKE_ARGS="
131
+ -DEXECUTORCH_BUILD_OPENVINO=" $OPENVINO " \
132
+ -DEXECUTORCH_BUILD_XNNPACK=" $XNNPACK " \
133
+ -DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
134
+ -DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
135
+ -DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \
136
+ -DEXECUTORCH_ENABLE_LOGGING=ON \
137
+ -DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
138
+ -DEXECUTORCH_BUILD_PYBIND=ON"
139
+
140
+ echo $TARGET_LIBS
141
+ export CMAKE_BUILD_ARGS=" --target $TARGET_LIBS "
142
+ pip install . --no-build-isolation
107
143
}
108
144
109
145
cmake_build_demo () {
110
146
echo " Building yolo12 runner"
111
- dir=" examples/models/yolo12"
112
147
retry cmake \
113
148
-DCMAKE_BUILD_TYPE=" $CMAKE_BUILD_TYPE " \
114
149
-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 "
150
+ -DUSE_XNNPACK_BACKEND =" $XNNPACK " \
151
+ -Bcmake-out/${DIR } \
152
+ ${DIR }
153
+ cmake --build cmake-out/${DIR } -j9 --config " $CMAKE_BUILD_TYPE "
119
154
120
155
}
121
156
122
157
cleanup_files () {
123
- true
158
+ rm $EXPORTED_MODEL_NAME
124
159
}
125
160
126
161
prepare_artifacts_upload () {
127
162
if [ -n " ${UPLOAD_DIR} " ]; then
128
- true
163
+ echo " Preparing for uploading generated artifacs"
164
+ zip -j model.zip " ${EXPORTED_MODEL_NAME} "
165
+ mkdir -p " ${UPLOAD_DIR} "
166
+ mv model.zip " ${UPLOAD_DIR} "
167
+ mv result.txt " ${UPLOAD_DIR} "
168
+
129
169
fi
130
170
}
131
171
@@ -141,14 +181,14 @@ cmake_install_executorch_libraries
141
181
$PYTHON_EXECUTABLE -m examples.models.yolo12.export_and_validate ${EXPORT_ARGS}
142
182
143
183
144
- RUNTIME_ARGS=" --model_path=${EXPORTED_MODEL_NAME} --input_path=${INPUT_VIDEO } "
184
+ RUNTIME_ARGS=" --model_path=${EXPORTED_MODEL_NAME} --input_path=${VIDEO_PATH } "
145
185
# Check build tool.
146
186
cmake_build_demo
147
- # Run llama runner
187
+ # Run yolo12 runner
148
188
NOW=$( date +" %H:%M:%S" )
149
- echo " Starting to run llama runner at ${NOW} "
189
+ echo " Starting to run yolo12 runner at ${NOW} "
150
190
# shellcheck source=/dev/null
151
- cmake-out/examples/models/yolo12/Yolo12Detection ${RUNTIME_ARGS} > result.txt
191
+ cmake-out/examples/models/yolo12/Yolo12DetectionDemo ${RUNTIME_ARGS} > result.txt
152
192
NOW=$( date +" %H:%M:%S" )
153
193
echo " Finished at ${NOW} "
154
194
0 commit comments