SAM2-hiera-tiny-OpenVINO
SAM2-hiera-tiny for Intel NPUs, GPUs and CPUs: sam2_decoder and sam2_encoder from mlboydaisuke/SAM2-hiera-tiny-LiteRT as ONNX (tf2onnx 1.17.0, opset 17), OpenVINO IR with fp32 weights, and precompiled Intel NPU blobs. tf2onnx 1.17.0 drops the bias of 6 FULLY_CONNECTED layers of sam2_decoder; these files were converted with a one-line fix of that handler (convert/patch_tf2onnx.py in the GitHub repo), and their outputs match the .tflite. On the NPU of a Core Ultra 9 386H the blob runs in 7.97 ms (sam2_decoder) and 1972.66 ms (sam2_encoder) per run, numpy input to numpy output.
Scripts, raw records, and the same table for all 52 graphs of LiteRT-Models: https://github.com/john-rocky/windows-zoo
Files
| file | bytes | sha256 |
|---|---|---|
sam2_decoder.onnx |
24,932,648 | bef9a8b8f8adb6bb41755f6d9153742ed51d8f51b105fbbfb67ead7d59f449ea |
openvino/sam2_decoder.xml |
755,917 | 775d174179109655fbb26e1e7bc1880cfa02d2dc2f4c7fd31d0d42de8f1800df |
openvino/sam2_decoder.bin |
24,421,952 | ce3bc5ab2832b822eaa6a9413802e2731120cb7184a01c74b1a8d6e8de617c59 |
npu/sam2_decoder.blob |
21,188,737 | 2326a9d867fb98556a44bbb442d2f201477e9ee3453b3e1345f2e5a515675797 |
sam2_encoder.onnx |
134,201,095 | 2377332c91031aa842d01d7bd53c1e3b772a2310d9c2925aed2b11e74fb59b4f |
openvino/sam2_encoder.xml |
890,720 | 91c371c1af7b9791f5bf214b4edcd7a7f7142f902481b44658630191801e6a26 |
openvino/sam2_encoder.bin |
134,055,208 | e33d8c1ebbd01b6b272ae008a32dd42b33b67153ae08501c4baeafed7a68163c |
npu/sam2_encoder.blob |
146,653,313 | e107d56b61d093e1d03be3b3b5d69c5436deb7126d2258ea9ffb5986da196c3b |
The NPU blobs were compiled with OpenVINO 2026.4.1, Intel NPU driver 32.0.100.4841 (OpenVINO reports NPU_DRIVER_VERSION 1004841, NPU_COMPILER_VERSION 524292). If import_model refuses a blob on another driver or OpenVINO version, compile the IR instead (the commented line in the snippet).
How it was measured
MSI Stealth 16 AI+ (Core Ultra 9 386H, RTX 5080 Laptop GPU at a 95 W power limit, Windows 11 build 26200.9711, on AC power), 2026-11-07. On the laptop, each row is one process: load, one run, 5 warmup runs, then the median of 30 timed runs (2 warmup + 10 timed runs when the first run takes more than 3 s), numpy input to numpy output, every runtime at its default settings, one process at a time, each started after the CPU, the RTX and the Intel GPU had gone idle (the thresholds are in METHOD.md of the GitHub repo). Output check: each output against the CPU output in fp32 on the same input (ONNX Runtime's CPU EP); PASS = cosine ≥ 0.99, no NaN or Inf, and top-1 agreement ≥ 0.99 for class scores. The Snapdragon rows are Qualcomm AI Hub profile jobs of the same ONNX files (their own timer). No Snapdragon rows for sam2_decoder: Qualcomm AI Hub measured the file before the bias fix (its numbers are in the GitHub table).
sam2_decoder
| processor | runtime | file | ms | load s | output check |
|---|---|---|---|---|---|
| Intel AI Boost NPU | OpenVINO 2026.4.1 | npu/ blob (import_model) |
7.97 | 0.02 | FAIL: output_0_output: cos 0.1192 < 0.99 |
| Intel AI Boost NPU | ONNX Runtime 1.31.1 + OpenVINO EP 1.8.1 | .onnx, compiled when the session loads |
9.82 | 4.15 | PASS (cos ≥ 0.9998) |
| Intel Graphics (iGPU) | ONNX Runtime 1.31.1 + OpenVINO EP 1.8.1 | .onnx |
11.29 | 1.19 | PASS (cos ≥ 0.9999) |
| RTX 5080 Laptop (95 W limit) | ONNX Runtime 1.31.1, CUDA EP | fp16 copy of the .onnx (not in this repo) |
4.58 | 1.23 | PASS (cos ≥ 0.9999) |
| RTX 5080 Laptop (95 W limit) | ONNX Runtime 1.31.1, CUDA EP | .onnx |
4.97 | 1.33 | PASS (cos ≥ 0.9999) |
| Core Ultra 9 386H CPU | ONNX Runtime 1.31.1, CPU EP | .onnx |
26.88 | 0.27 | reference |
The ONNX file against the source .tflite (LiteRT interpreter on the CPU, the same input): PASS, cosine ≥ 0.9999 for every output.
sam2_encoder
| processor | runtime | file | ms | load s | output check |
|---|---|---|---|---|---|
| Intel AI Boost NPU | OpenVINO 2026.4.1 | npu/ blob (import_model) |
1972.66 | 0.14 | PASS (cos ≥ 0.9999) |
| Intel AI Boost NPU | ONNX Runtime 1.31.1 + OpenVINO EP 1.8.1 | .onnx, compiled when the session loads |
106.59 | 225.12 | PASS (cos ≥ 0.9999) |
| Intel Graphics (iGPU) | ONNX Runtime 1.31.1 + OpenVINO EP 1.8.1 | .onnx |
156.36 | 1.55 | PASS (cos ≥ 0.9999) |
| RTX 5080 Laptop (95 W limit) | ONNX Runtime 1.31.1, CUDA EP | fp16 copy of the .onnx (not in this repo) |
28.01 | 1.27 | PASS (cos ≥ 0.9999) |
| RTX 5080 Laptop (95 W limit) | ONNX Runtime 1.31.1, CUDA EP | .onnx |
46.41 | 1.26 | PASS (cos ≥ 0.9999) |
| Core Ultra 9 386H CPU | ONNX Runtime 1.31.1, CPU EP | .onnx |
2200.98 | 0.33 | reference |
| Snapdragon X2 Elite NPU | Qualcomm AI Hub, ONNX Runtime QNN EP | .onnx, compiled when it loads |
191.09 (1 layers on the CPU) | 139.87 | not compared (AI Hub profile job, 2026-10-30) |
The ONNX file against the source .tflite (LiteRT interpreter on the CPU, the same input): PASS, cosine ≥ 0.9999 for every output.
Run it on the Intel NPU
Download this repo, then run the snippets from its folder:
pip install huggingface_hub
hf download mlboydaisuke/SAM2-hiera-tiny-OpenVINO --local-dir SAM2-hiera-tiny-OpenVINO
cd SAM2-hiera-tiny-OpenVINO
OpenVINO (pip install openvino==2026.4.1):
import numpy as np
import openvino as ov
core = ov.Core()
if "NPU" not in core.available_devices:
raise SystemExit(f"no Intel NPU visible to OpenVINO: {core.available_devices}")
with open("npu/sam2_decoder.blob", "rb") as f:
compiled = core.import_model(f.read(), "NPU") # precompiled: no compile at load
# or compile the IR on this machine: compiled = core.compile_model("openvino/sam2_decoder.xml", "NPU")
# replace the zeros with your preprocessed input (float32, the shapes printed by compiled.inputs)
feeds = {i.get_any_name(): np.zeros(list(i.shape), np.float32) for i in compiled.inputs}
outputs = compiled(feeds)
print({o.get_any_name(): outputs[o].shape for o in compiled.outputs})
ONNX Runtime with the OpenVINO EP (pip install onnxruntime==1.31.1 onnxruntime-ep-openvino==1.8.1):
import numpy as np
import onnxruntime as ort
import onnxruntime_ep_openvino as ov_ep
ort.register_execution_provider_library(ov_ep.get_ep_name(), ov_ep.get_library_path())
npu = [d for d in ort.get_ep_devices()
if d.ep_name == ov_ep.get_ep_name() and d.ep_metadata.get("ov_device") == "NPU"]
if not npu:
raise SystemExit("no Intel NPU visible to the OpenVINO EP")
so = ort.SessionOptions()
so.add_provider_for_devices(npu, {})
sess = ort.InferenceSession("sam2_decoder.onnx", sess_options=so) # compiles for the NPU here
# replace the zeros with your preprocessed input (float32)
feeds = {i.name: np.zeros(i.shape, np.float32) for i in sess.get_inputs()}
outputs = sess.run(None, feeds)
print([o.shape for o in outputs])
The same lines run sam2_encoder with its own file names.
Licence
Apache-2.0, the licence of mlboydaisuke/SAM2-hiera-tiny-LiteRT. The upstream model: facebook/sam2.1-hiera-tiny.
Model tree for mlboydaisuke/SAM2-hiera-tiny-OpenVINO
Base model
facebook/sam2.1-hiera-tiny