Skip to content

Commit 6a9d749

Browse files
[Examples] Yolo26 Sample for OpenVINO/XNNPACK (pytorch#18583)
### Summary Yolo12 is replaced by the Yolo26 model in the examples ### Test plan Local sanity check | CPU | Backend | Model | Precision | Average detection time, ms 1920x1080 | |--------------------------------------------|----------|---------|-----------|------------------------| | Intel(R) Core(TM) i9-10980XE CPU @ 3.00GHz | OpenVINO | Yolo26s | FP32 | 159.48 | | Intel(R) Core(TM) i9-10980XE CPU @ 3.00GHz | OpenVINO | Yolo26s | INT8 | 73 | | Intel(R) Core(TM) i9-10980XE CPU @ 3.00GHz | XNNPACK | Yolo26s | FP32 | 312.403 | | Intel(R) Core(TM) i9-10980XE CPU @ 3.00GHz | XNNPACK | Yolo26s | INT8 | 267.609 | test_yolo26.sh is running ok on my local machine, please help me to validate the .ci/scripts/test_yolo26.sh CC: @mergennachin @lucylq --------- Co-authored-by: Surya Siddharth Pemmaraju <surya.siddharth.pemmaraju@intel.com>
1 parent 0af4992 commit 6a9d749

12 files changed

Lines changed: 240 additions & 261 deletions

File tree

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# LICENSE file in the root directory of this source tree.
77

88
set -ex
9+
910
# shellcheck source=/dev/null
1011
source "$(dirname "${BASH_SOURCE[0]}")/utils.sh"
1112

@@ -50,21 +51,21 @@ PT2E_QUANTIZE="${PT2E_QUANTIZE:-}"
5051
# Default CMake Build Type to release mode
5152
CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-Release}
5253

53-
if [[ $# -lt 5 ]]; then # Assuming 4 mandatory args
54-
echo "Expecting atleast 5 positional arguments"
55-
echo "Usage: [...]"
56-
fi
5754
if [[ -z "${MODEL_NAME:-}" ]]; then
5855
echo "Missing model name, exiting..."
5956
exit 1
6057
fi
6158

62-
6359
if [[ -z "${MODE:-}" ]]; then
6460
echo "Missing mode, choose openvino or xnnpack, exiting..."
6561
exit 1
6662
fi
6763

64+
if [[ -z "${VIDEO_PATH:-}" ]]; then
65+
echo "Missing video path, exiting..."
66+
exit 1
67+
fi
68+
6869
if [[ -z "${PYTHON_EXECUTABLE:-}" ]]; then
6970
PYTHON_EXECUTABLE=python3
7071
fi
@@ -75,21 +76,13 @@ if [[ "${MODE}" =~ .*openvino.* ]]; then
7576
OPENVINO=ON
7677
TARGET_LIBS="$TARGET_LIBS openvino_backend "
7778

78-
git clone https://github.com/openvinotoolkit/openvino.git
79-
cd openvino && git b16b776ac119dafda51f69a80f1e6b7376d02c3b
80-
git submodule update --init --recursive
81-
sudo ./install_build_dependencies.sh
82-
mkdir build && cd build
83-
cmake .. -DCMAKE_BUILD_TYPE=Release -DENABLE_PYTHON=ON
84-
make -j$(nproc)
85-
86-
cd ..
87-
cmake --install build --prefix dist
88-
89-
source dist/setupvars.sh
90-
cd ../backends/openvino
91-
pip install -r requirements.txt
92-
cd ../../
79+
# Install specific OpenVINO runtime from pip.
80+
$PYTHON_EXECUTABLE -m pip install --pre openvino==2026.1.0.dev20260131 --extra-index-url https://storage.openvinotoolkit.org/simple/wheels/nightly
81+
$PYTHON_EXECUTABLE -m pip install -r backends/openvino/requirements.txt
82+
83+
# Set OPENVINO_LIB_PATH so the C++ demo runner can also find libopenvino_c.so.
84+
OPENVINO_LIB_PATH=$($PYTHON_EXECUTABLE -c "import openvino, os, glob; print(sorted(glob.glob(os.path.join(os.path.dirname(openvino.__file__), 'libs', 'libopenvino_c.so*')))[-1])")
85+
export OPENVINO_LIB_PATH
9386
else
9487
OPENVINO=OFF
9588
fi
@@ -103,9 +96,10 @@ fi
10396

10497
which "${PYTHON_EXECUTABLE}"
10598

99+
TORCH_URL=https://download.pytorch.org/whl/cpu
106100

107-
DIR="examples/models/yolo12"
108-
$PYTHON_EXECUTABLE -m pip install -r ${DIR}/requirements.txt
101+
DIR="examples/models/yolo26"
102+
$PYTHON_EXECUTABLE -m pip install --upgrade-strategy only-if-needed --extra-index-url "$TORCH_URL" -r ${DIR}/requirements.txt
109103

110104
cmake_install_executorch_libraries() {
111105
rm -rf cmake-out
@@ -142,11 +136,11 @@ cmake_install_executorch_libraries() {
142136

143137
echo $TARGET_LIBS
144138
export CMAKE_BUILD_ARGS="--target $TARGET_LIBS"
145-
pip install . --no-build-isolation
139+
$PYTHON_EXECUTABLE -m pip install . --no-build-isolation
146140
}
147141

148142
cmake_build_demo() {
149-
echo "Building yolo12 runner"
143+
echo "Building yolo26 runner"
150144
retry cmake \
151145
-DCMAKE_BUILD_TYPE="$CMAKE_BUILD_TYPE" \
152146
-DUSE_OPENVINO_BACKEND="$OPENVINO" \
@@ -174,24 +168,29 @@ prepare_artifacts_upload() {
174168

175169

176170
# Export model.
177-
EXPORTED_MODEL_NAME="${MODEL_NAME}_fp32_${MODE}.pte"
178-
echo "Exporting ${EXPORTED_MODEL_NAME}"
179171
EXPORT_ARGS="--model_name=${MODEL_NAME} --backend=${MODE}"
172+
if [[ -n "${PT2E_QUANTIZE}" ]]; then
173+
EXPORTED_MODEL_NAME="${MODEL_NAME}_int8_${MODE}.pte"
174+
EXPORT_ARGS="${EXPORT_ARGS} --quantize --video_path=${VIDEO_PATH}"
175+
else
176+
EXPORTED_MODEL_NAME="${MODEL_NAME}_fp32_${MODE}.pte"
177+
fi
178+
echo "Exporting ${EXPORTED_MODEL_NAME}"
180179

181180
# Add dynamically linked library location
182181
cmake_install_executorch_libraries
183182

184-
$PYTHON_EXECUTABLE -m examples.models.yolo12.export_and_validate ${EXPORT_ARGS}
183+
$PYTHON_EXECUTABLE -m examples.models.yolo26.export_and_validate ${EXPORT_ARGS}
185184

186185

187186
RUNTIME_ARGS="--model_path=${EXPORTED_MODEL_NAME} --input_path=${VIDEO_PATH}"
188187
# Check build tool.
189188
cmake_build_demo
190-
# Run yolo12 runner
189+
# Run yolo26 runner
191190
NOW=$(date +"%H:%M:%S")
192-
echo "Starting to run yolo12 runner at ${NOW}"
191+
echo "Starting to run yolo26 runner at ${NOW}"
193192
# shellcheck source=/dev/null
194-
cmake-out/examples/models/yolo12/Yolo12DetectionDemo ${RUNTIME_ARGS} > result.txt
193+
cmake-out/examples/models/yolo26/Yolo26DetectionDemo ${RUNTIME_ARGS} > result.txt
195194
NOW=$(date +"%H:%M:%S")
196195
echo "Finished at ${NOW}"
197196

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ ExecuTorch powers on-device AI at scale across Meta's family of apps, VR/AR devi
204204

205205
**Multimodal:** [Llava](examples/models/llava/README.md) (vision-language), [Voxtral](examples/models/voxtral/README.md) (audio-language), [Gemma](examples/models/gemma3) (vision-language)
206206

207-
**Vision/Speech:** [MobileNetV2](https://github.com/meta-pytorch/executorch-examples/tree/main/mv2), [DeepLabV3](https://github.com/meta-pytorch/executorch-examples/tree/main/dl3), [Whisper](examples/models/whisper/README.md) <!-- @lint-ignore -->
207+
**Vision/Speech:** [MobileNetV2](https://github.com/meta-pytorch/executorch-examples/tree/main/mv2), [DeepLabV3](https://github.com/meta-pytorch/executorch-examples/tree/main/dl3), [YOLO26](examples/models/yolo26/README.md), [Whisper](examples/models/whisper/README.md) <!-- @lint-ignore -->
208208

209209
**Resources:** [`examples/`](examples/) directory • [executorch-examples](https://github.com/meta-pytorch/executorch-examples) out-of-tree demos • [Optimum-ExecuTorch](https://github.com/huggingface/optimum-executorch) for HuggingFace models • [Unsloth](https://docs.unsloth.ai/new/deploy-llms-phone) for fine-tuned LLM deployment <!-- @lint-ignore -->
210210

backends/openvino/quantizer/quantizer.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,18 @@ def set_ignored_scope(
192192
:param validate: If set to True, then a RuntimeError will be raised if any ignored scope does not match
193193
in the model graph.
194194
"""
195+
subgraphs_ = []
196+
if subgraphs:
197+
subgraphs_ = [
198+
nncf.Subgraph(inputs=subgraph[0], outputs=subgraph[1])
199+
for subgraph in subgraphs
200+
]
195201
self._algo.set_ignored_scope(
196202
nncf.IgnoredScope(
197203
names=names or [],
198204
patterns=patterns or [],
199205
types=types or [],
200-
subgraphs=subgraphs or [],
206+
subgraphs=subgraphs_,
201207
validate=validate,
202208
)
203209
)

docs/source/success-stories.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ Automate PyTorch model deployment to iOS, Android, and edge devices with ExecuTo
156156

157157
- **LoRA adapter** - Export two LoRA adapters that share a single foundation weight file, saving memory and disk space. [Try →](https://github.com/meta-pytorch/executorch-examples/tree/main/program-data-separation/cpp/lora_example)
158158

159-
- **OpenVINO from Intel** - Deploy [Yolo12](https://github.com/pytorch/executorch/tree/main/examples/models/yolo12), [Llama](https://github.com/pytorch/executorch/tree/main/examples/openvino/llama), and [Stable Diffusion](https://github.com/pytorch/executorch/tree/main/examples/openvino/stable_diffusion) on [OpenVINO from Intel](https://www.intel.com/content/www/us/en/developer/articles/community/optimizing-executorch-on-ai-pcs.html).
159+
- **OpenVINO from Intel** - Deploy [Yolo26](https://github.com/pytorch/executorch/tree/main/examples/models/yolo26), [Llama](https://github.com/pytorch/executorch/tree/main/examples/openvino/llama), and [Stable Diffusion](https://github.com/pytorch/executorch/tree/main/examples/openvino/stable_diffusion) on [OpenVINO from Intel](https://www.intel.com/content/www/us/en/developer/articles/community/optimizing-executorch-on-ai-pcs.html).
160160

161161
- **Audio Generation** - Generate audio from text prompts using Stable Audio Open Small on Arm CPUs with XNNPACK and KleidiAI. [Try →](https://github.com/Arm-Examples/ML-examples/tree/main/kleidiai-examples/audiogen-et)[Video →](https://www.youtube.com/watch?v=q2P0ESVxhAY) <!-- @lint-ignore -->
162162

examples/models/yolo12/inference.h

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

examples/models/yolo12/requirements.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required(VERSION 3.5)
22

3-
project(Yolo12DetectionDemo VERSION 0.1)
3+
project(Yolo26DetectionDemo VERSION 0.1)
44

55
option(USE_OPENVINO_BACKEND "Build the tutorial with the OPENVINO backend" OFF)
66
option(USE_XNNPACK_BACKEND "Build the tutorial with the XNNPACK backend" OFF)
@@ -44,7 +44,8 @@ if(USE_XNNPACK_BACKEND)
4444
endif()
4545

4646
if(USE_OPENVINO_BACKEND)
47-
find_package(OpenVINO REQUIRED)
47+
# The OpenVINO backend resolves symbols via dlopen at runtime, so there is no
48+
# build-time dependency on the OpenVINO SDK (no find_package needed).
4849
list(APPEND link_libraries openvino_backend)
4950
executorch_target_link_options_shared_lib(openvino_backend)
5051
endif()
@@ -63,14 +64,14 @@ set(PROJECT_SOURCES
6364
${EXECUTORCH_ROOT}/extension/runner_util/inputs_portable.cpp
6465
)
6566

66-
add_executable(Yolo12DetectionDemo ${PROJECT_SOURCES})
67+
add_executable(Yolo26DetectionDemo ${PROJECT_SOURCES})
6768
target_link_libraries(
68-
Yolo12DetectionDemo PUBLIC ${link_libraries} ${OpenCV_LIBS} executorch_core
69+
Yolo26DetectionDemo PUBLIC ${link_libraries} ${OpenCV_LIBS} executorch_core
6970
extension_module extension_tensor
7071
)
7172

7273
find_package(Threads REQUIRED)
73-
target_link_libraries(Yolo12DetectionDemo PRIVATE Threads::Threads)
74+
target_link_libraries(Yolo26DetectionDemo PRIVATE Threads::Threads)
7475
target_include_directories(
75-
Yolo12DetectionDemo PUBLIC ${_common_include_directories}
76+
Yolo26DetectionDemo PUBLIC ${_common_include_directories}
7677
)

0 commit comments

Comments
 (0)