55# This source code is licensed under the BSD-style license found in the
66# LICENSE file in the root directory of this source tree.
77
8- set -exu
8+ set -ex
99# shellcheck source=/dev/null
1010source " $( dirname " ${BASH_SOURCE[0]} " ) /utils.sh"
1111
@@ -65,11 +65,32 @@ if [[ -z "${MODE:-}" ]]; then
6565 exit 1
6666fi
6767
68+ if [[ -z " ${PYTHON_EXECUTABLE:- } " ]]; then
69+ PYTHON_EXECUTABLE=python3
70+ fi
71+
6872TARGET_LIBS=" "
6973
7074if [[ " ${MODE} " =~ .* openvino.* ]]; then
7175 OPENVINO=ON
7276 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 ../../
7394else
7495 OPENVINO=OFF
7596fi
@@ -81,51 +102,70 @@ else
81102 XNNPACK=OFF
82103fi
83104
84- if [[ -z " ${PYTHON_EXECUTABLE:- } " ]]; then
85- PYTHON_EXECUTABLE=python3
86- fi
87-
88105which " ${PYTHON_EXECUTABLE} "
89106
107+
108+ DIR=" examples/models/yolo12"
109+ $PYTHON_EXECUTABLE -m pip install -r ${DIR} /requirements.txt
110+
90111cmake_install_executorch_libraries () {
91- echo " Installing libexecutorch.a, libextension_module.so, libportable_ops_lib.a"
92112 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
107143}
108144
109145cmake_build_demo () {
110146 echo " Building yolo12 runner"
111- dir=" examples/models/yolo12"
112147 retry cmake \
113148 -DCMAKE_BUILD_TYPE=" $CMAKE_BUILD_TYPE " \
114149 -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 "
119154
120155}
121156
122157cleanup_files () {
123- true
158+ rm $EXPORTED_MODEL_NAME
124159}
125160
126161prepare_artifacts_upload () {
127162 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+
129169 fi
130170}
131171
@@ -141,14 +181,14 @@ cmake_install_executorch_libraries
141181$PYTHON_EXECUTABLE -m examples.models.yolo12.export_and_validate ${EXPORT_ARGS}
142182
143183
144- RUNTIME_ARGS=" --model_path=${EXPORTED_MODEL_NAME} --input_path=${INPUT_VIDEO } "
184+ RUNTIME_ARGS=" --model_path=${EXPORTED_MODEL_NAME} --input_path=${VIDEO_PATH } "
145185# Check build tool.
146186cmake_build_demo
147- # Run llama runner
187+ # Run yolo12 runner
148188NOW=$( date +" %H:%M:%S" )
149- echo " Starting to run llama runner at ${NOW} "
189+ echo " Starting to run yolo12 runner at ${NOW} "
150190# 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
152192NOW=$( date +" %H:%M:%S" )
153193echo " Finished at ${NOW} "
154194
0 commit comments