@ultralytics/yolo 0.0.54 → 0.0.56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -82,7 +82,7 @@ await annotate(document.querySelector("canvas"), "bus.jpg", results);
82
82
 
83
83
  `predict()` accepts a URL/path, a `Blob`/`File`, raw encoded image bytes
84
84
  (`Uint8Array`/`ArrayBuffer`), `ImageData`, an `HTMLImageElement`,
85
- `HTMLCanvasElement`, `HTMLVideoElement`, or an `ImageBitmap`.
85
+ `HTMLCanvasElement`, `HTMLVideoElement`, an `OffscreenCanvas`, or an `ImageBitmap`.
86
86
 
87
87
  ```ts
88
88
  const results = await model.predict(canvas, { conf: 0.25, iou: 0.7 });
@@ -184,6 +184,10 @@ await annotate(canvas, img, results, { keypointRadius: 4, skeleton: [[0, 1]] });
184
184
  `annotate()` also takes `lineWidth` and `font` to set the box width and label font, and `labels: false` or
185
185
  `keypoints: false` to hide labels or keypoints.
186
186
 
187
+ Arabic, Hebrew and other right-to-left class names are drawn right to left in every browser, Safari included. They use
188
+ the engine's wasm, so if `annotate()` runs where no model was loaded (for example on the main thread while a worker runs
189
+ the model), pass the same `wasmUrl` you gave `YOLO.load`.
190
+
187
191
  ## ⚙️ Requirements & Notes
188
192
 
189
193
  - **WebGPU** (Chrome/Edge, or Firefox with WebGPU enabled) from a **secure
@@ -193,14 +197,12 @@ await annotate(canvas, img, results, { keypointRadius: 4, skeleton: [[0, 1]] });
193
197
  `YOLO.load("/models/yolo26n.onnx", { device: "webgpu" | "cpu" })` (default `"auto"`). If
194
198
  WebGPU cannot engage, the load falls back to CPU; `model.device` reports what
195
199
  actually ran.
200
+ - **Workers**: LiteRT image inputs and timing support worker globals; LiteRT's own worker asset
201
+ loading requirements still apply. The ONNX Runtime Web loader requires a browser window.
196
202
  - **RT-DETR**: supported for detection. An RT-DETR `.onnx` runs on WebGPU like any other
197
- model. An RT-DETR `.tflite` is routed to CPU/wasm under the default `device: "auto"`: its
198
- deformable-attention decoder reshapes to rank 5 and indexes with `int64`, which the LiteRT
199
- WebGPU delegate rejected on every driver tested (Linux/Vulkan and Apple Metal-3). An
200
- explicit `device: "webgpu"` is still attempted rather than overridden, so the delegate can
201
- be re-tested as it gains ops; on current drivers that attempt fails and LiteRT falls back
202
- to CPU/wasm, and `model.device` reports what ran. Export one yourself, since no RT-DETR
203
- ONNX or LiteRT model is published.
203
+ model. LiteRT models that cannot be fully delegated to WebGPU run on CPU/wasm;
204
+ `model.device` reports the selected device. Export an RT-DETR model yourself, since
205
+ no ONNX or LiteRT model is published.
204
206
  - **Model format**: export your model to ONNX with Ultralytics `>=8.4.142` so the metadata
205
207
  (task, class names, `imgsz`) is embedded:
206
208
 
@@ -302,23 +304,19 @@ Notes:
302
304
  embedded metadata) ships in
303
305
  [v8.4.83](https://github.com/ultralytics/ultralytics/releases/tag/v8.4.83) and
304
306
  later. Earlier versions emit the legacy TFLite format and won't load here.
305
- - **Keep the one-to-many head for WebGPU** (`nms=None`): the NMS-free YOLO26 head, exported
306
- with `nms=False`, has `int64` / `gather_nd` ops the LiteRT **WebGPU** delegate cannot
307
- run, so those exports fall back to CPU/wasm. Use Ultralytics `>=8.4.142` for this recipe; it exports
308
- the one-to-many head by default, so NMS runs in this package's Rust and inference stays
309
- on WebGPU:
307
+ - **NMS-free models**: recent YOLO26 LiteRT exports use GPU-compatible operators. Older
308
+ exports contain operations that may prevent full WebGPU delegation; those run on CPU/wasm.
309
+ Alternatively, export the one-to-many head to run NMS in Rust:
310
310
 
311
311
  ```bash
312
312
  yolo export model=yolo26n.pt format=litert nms=None
313
313
  ```
314
314
 
315
- If you load an NMS-free `.tflite`, the backend auto-switches it to wasm
316
- (slower) and logs a warning rather than returning empty results.
317
-
318
315
  - **Tasks**: detect, segment, semantic, depth, classify, pose, and obb are all supported.
319
316
  - **Cross-origin isolation**: LiteRT's threaded wasm wants `SharedArrayBuffer`,
320
317
  so serve with `Cross-Origin-Opener-Policy: same-origin` and
321
- `Cross-Origin-Embedder-Policy: require-corp`.
318
+ `Cross-Origin-Embedder-Policy: require-corp`. That blocks the default CDN wasm, so
319
+ pass a same-origin `litertWasmUrl` too.
322
320
 
323
321
  ## 🏎️ Benchmarks
324
322
 
@@ -336,8 +334,7 @@ ONNX Runtime Web (`.onnx`):
336
334
 
337
335
  Apple M4, Chrome 153, `@ultralytics/yolo` 0.0.48 (ONNX Runtime Web 1.27, LiteRT.js 2.5.3). FP32 640×640 models
338
336
  exported with Ultralytics 8.4.163 (`nms=None`), cycling through the 128 COCO128 images after warmup (128 timed runs on
339
- WebGPU, 50 on CPU). NMS-free exports (`nms=False`) run at the same speed on ONNX Runtime Web, but LiteRT.js falls back
340
- to CPU/wasm for them, so keep `nms=None` for WebGPU.
337
+ WebGPU, 50 on CPU). Recent NMS-free LiteRT exports (`nms=False`) can also run on WebGPU.
341
338
 
342
339
  ## 🔨 Building From Source
343
340
 
package/README.zh-CN.md CHANGED
@@ -79,7 +79,7 @@ await annotate(document.querySelector("canvas"), "bus.jpg", results);
79
79
  ```
80
80
 
81
81
  `predict()` 接受 URL/路径、`Blob`/`File`、原始编码图片字节(`Uint8Array`/`ArrayBuffer`)、
82
- `ImageData`、`HTMLImageElement`、`HTMLCanvasElement`、`HTMLVideoElement` 或 `ImageBitmap`。
82
+ `ImageData`、`HTMLImageElement`、`HTMLCanvasElement`、`HTMLVideoElement`、`OffscreenCanvas` 或 `ImageBitmap`。
83
83
 
84
84
  ```ts
85
85
  const results = await model.predict(canvas, { conf: 0.25, iou: 0.7 });
@@ -177,6 +177,9 @@ await annotate(canvas, img, results, { keypointRadius: 4, skeleton: [[0, 1]] });
177
177
  `annotate()` 还接受 `lineWidth` 和 `font` 用于设置框线宽度和标签字体,以及 `labels: false` 或
178
178
  `keypoints: false` 用于隐藏标签或关键点。
179
179
 
180
+ 阿拉伯语、希伯来语等从右到左的类别名在所有浏览器(包括 Safari)中都会从右到左绘制。这需要引擎的 wasm,
181
+ 因此如果 `annotate()` 运行在未加载模型的线程中(例如模型在 worker 中运行而绘制在主线程),请传入与 `YOLO.load` 相同的 `wasmUrl`。
182
+
180
183
  ## ⚙️ 环境要求与注意事项
181
184
 
182
185
  - **WebGPU**(Chrome/Edge,或启用了 WebGPU 的 Firefox)配合**安全上下文**(`https://` 或
@@ -184,13 +187,11 @@ await annotate(canvas, img, results, { keypointRadius: 4, skeleton: [[0, 1]] });
184
187
  `YOLO.load` 会自动回退到通用的 **CPU/wasm** 构建,随处可用。可通过
185
188
  `YOLO.load("/models/yolo26n.onnx", { device: "webgpu" | "cpu" })` 指定设备(默认 `"auto"`)。若 WebGPU
186
189
  无法启用,加载会回退到 CPU;`model.device` 会报告实际使用的设备。
187
- - **RT-DETR**:支持检测任务。RT-DETR 的 `.onnx` 可以像其他模型一样在 WebGPU 上运行;而
188
- RT-DETR 的 `.tflite` 在默认的 `device: "auto"` 下会被路由到 CPU/wasm,因为它的可变形注意力
189
- 解码器会 reshape 到 5 维并使用 `int64` 索引,目前测试过的所有驱动(Linux/Vulkan 与 Apple
190
- Metal-3)上 LiteRT 的 WebGPU delegate 都会拒绝这些算子。显式指定 `device: "webgpu"` 仍会
191
- 尝试使用 delegate,而不会被强制覆盖,便于在 delegate 补齐算子后重新测试;在当前驱动上该
192
- 尝试会失败,LiteRT 会回退到 CPU/wasm,`model.device` 会报告实际使用的设备。官方没有发布
193
- RT-DETR 的 ONNX 或 LiteRT 模型,需要自行导出。
190
+ - **Worker**:LiteRT 图像输入和计时支持 worker 环境,但仍须满足 LiteRT 自身的 worker 资源加载要求。
191
+ ONNX Runtime Web 加载器需要浏览器窗口。
192
+ - **RT-DETR**:支持检测任务。RT-DETR 的 `.onnx` 可以像其他模型一样在 WebGPU 上运行。
193
+ 无法完全委托给 WebGPU 的 LiteRT 模型会在 CPU/wasm 上运行,`model.device` 会报告实际使用的设备。
194
+ 官方没有发布 RT-DETR 的 ONNX 或 LiteRT 模型,需要自行导出。
194
195
  - **模型格式**:请使用 Ultralytics `>=8.4.142` 导出为 ONNX,以便元数据(任务、类别名称、`imgsz`)被嵌入模型:
195
196
 
196
197
  ```python
@@ -280,21 +281,17 @@ wasm 默认从 jsDelivr CDN 加载;向 `YOLO.load` 传入 `litertWasmUrl: "/li
280
281
  - **现有模型兼容性**:带内嵌元数据的单文件 LiteRT 导出自
281
282
  [v8.4.83](https://github.com/ultralytics/ultralytics/releases/tag/v8.4.83) 起提供。更早的版本
282
283
  会导出旧版 TFLite 格式,无法在这里加载。
283
- - **为 WebGPU 保留一对多检测头**(`nms=None`):以 `nms=False` 导出的 YOLO26 无 NMS 检测头包含
284
- `int64` / `gather_nd` 算子,无法在 LiteRT 的 **WebGPU** delegate 上运行,因此这类导出会
285
- 回退到 CPU/wasm。以下命令需要 Ultralytics `>=8.4.142`,默认导出一对多检测头,NMS 由本包的 Rust 代码执行,
286
- 推理得以保持在 WebGPU 上:
284
+ - **无 NMS 模型**:较新的 YOLO26 LiteRT 导出使用兼容 GPU 的算子。旧版导出可能包含无法完全委托给
285
+ WebGPU 的算子,此时模型会在 CPU/wasm 上运行。也可以导出一对多检测头,由 Rust 执行 NMS:
287
286
 
288
287
  ```bash
289
288
  yolo export model=yolo26n.pt format=litert nms=None
290
289
  ```
291
290
 
292
- 如果加载了无 NMS 的 `.tflite`,后端会自动切换到 wasm(较慢)并打印警告,而不是返回空结果。
293
-
294
291
  - **支持的任务**:detect、segment、semantic、depth、classify、pose 和 obb 均已支持。
295
292
  - **跨源隔离**:LiteRT 的多线程 wasm 需要 `SharedArrayBuffer`,因此请以
296
293
  `Cross-Origin-Opener-Policy: same-origin` 和 `Cross-Origin-Embedder-Policy: require-corp`
297
- 提供服务。
294
+ 提供服务。这会拦截默认 CDN 上的 wasm,因此还需传入同源的 `litertWasmUrl`。
298
295
 
299
296
  ## 🏎️ 基准测试
300
297
 
@@ -312,8 +309,7 @@ Web(`.onnx`):
312
309
 
313
310
  测试环境:Apple M4、Chrome 153、`@ultralytics/yolo` 0.0.48(ONNX Runtime Web 1.27、LiteRT.js 2.5.3)。模型为使用
314
311
  Ultralytics 8.4.163 导出的 FP32 640×640 模型(`nms=None`),预热后循环使用 COCO128 的 128 张图像(WebGPU 计时 128 次,CPU
315
- 计时 50 次)。无 NMS 导出(`nms=False`)在 ONNX Runtime Web 上速度相同,但 LiteRT.js 会回退到 CPU/wasm 运行,因此 WebGPU
316
- 请保持 `nms=None`。
312
+ 计时 50 次)。较新的无 NMS LiteRT 导出(`nms=False`)也可以在 WebGPU 上运行。
317
313
 
318
314
  ## 🔨 从源码构建
319
315
 
package/dist/index.d.ts CHANGED
@@ -82,8 +82,8 @@ export interface LoadOptions {
82
82
  * Optional base URL to self-host the ONNX Runtime Web build instead of
83
83
  * fetching it from `cdn.pyke.io`. The directory must contain
84
84
  * `ort.webgpu.min.js`, `ort-wasm-simd-threaded.jsep.wasm`, and
85
- * `ort-wasm-simd-threaded.jsep.mjs` for WebGPU, plus `ort.wasm.min.js` and
86
- * `ort-wasm-simd-threaded.wasm` for the CPU build, which is what a `"cpu"`
85
+ * `ort-wasm-simd-threaded.jsep.mjs` for WebGPU, plus `ort.wasm.min.js`,
86
+ * `ort-wasm-simd-threaded.wasm`, and `ort-wasm-simd-threaded.mjs` for the CPU build, which is what a `"cpu"`
87
87
  * device and the WebGPU fallback below load. Use an absolute URL ending in `/`.
88
88
  */
89
89
  ortBaseUrl?: string | URL;
@@ -159,15 +159,21 @@ export interface AnnotateOptions {
159
159
  * annotator); `1` shows the raw colorized depth map, `0` shows only the source.
160
160
  */
161
161
  depthAlpha?: number;
162
+ /**
163
+ * Optional URL/path to the wasm binary, as in {@link LoadOptions.wasmUrl}. Labels with
164
+ * right-to-left text need the engine, so pass it when no model has loaded it in this thread.
165
+ */
166
+ wasmUrl?: string | URL;
162
167
  }
163
168
  /** Image-like inputs accepted by {@link YOLO.predict}. */
164
- export type ImageInput = string | URL | Blob | ArrayBuffer | Uint8Array | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap;
169
+ export type ImageInput = string | URL | Blob | ArrayBuffer | Uint8Array | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas | ImageBitmap;
165
170
  /**
166
171
  * A loaded YOLO model. Loading is asynchronous, so use {@link YOLO.load} instead
167
172
  * of a constructor.
168
173
  */
169
174
  export declare class YOLO {
170
175
  private readonly engine;
176
+ private queue;
171
177
  private constructor();
172
178
  /**
173
179
  * Load a model and initialize the inference backend.
@@ -193,7 +199,7 @@ export declare class YOLO {
193
199
  * Run inference on an image.
194
200
  *
195
201
  * Drawable sources (`ImageData`, `HTMLImageElement`, `HTMLCanvasElement`,
196
- * `HTMLVideoElement`, `ImageBitmap`) take a fast path that reads raw pixels
202
+ * `HTMLVideoElement`, `OffscreenCanvas`, `ImageBitmap`) take a fast path that reads raw pixels
197
203
  * with no re-encoding, ideal for webcam/video. URLs, `Blob`s, and raw bytes
198
204
  * are decoded (in wasm for `ort`, via a canvas for `litert`).
199
205
  *
package/dist/index.js CHANGED
@@ -17,7 +17,7 @@
17
17
  * }
18
18
  * ```
19
19
  */
20
- import init, { YoloModel, YoloPipeline, start, pose_palette } from "../pkg/ultralytics_inference_web.js";
20
+ import init, { YoloModel, YoloPipeline, start, pose_palette, bidi_runs } from "../pkg/ultralytics_inference_web.js";
21
21
  let poseSchemeCache = null;
22
22
  /** The Ultralytics pose skeleton + per-keypoint/limb colors (constant). */
23
23
  function poseScheme() {
@@ -39,9 +39,7 @@ async function resolveDevice(pref) {
39
39
  console.warn("[@ultralytics/yolo] WebGPU requested but no adapter found; running on CPU.");
40
40
  return "cpu";
41
41
  }
42
- /** Ultralytics default thresholds (mirrored in the option JSDoc above). */
43
- const DEFAULT_CONF = 0.25;
44
- const DEFAULT_IOU = 0.7;
42
+ /** Ultralytics default keypoint confidence threshold for drawing. */
45
43
  const DEFAULT_KEYPOINT_THRESHOLD = 0.25;
46
44
  /** Whether `bytes` begin with a TFLite flatbuffer (the `TFL3` identifier at offset 4). */
47
45
  function isTflite(bytes) {
@@ -73,33 +71,24 @@ function decodeResults(raw) {
73
71
  r.semantic_mask = sem && sem.length ? new Uint16Array(sem.buffer, sem.byteOffset, sem.length / 2) : undefined;
74
72
  return r;
75
73
  }
76
- let initialized = false;
77
- /**
78
- * `ort-web` 0.4.0 reads tensor dims as 64-bit integers, but ONNX Runtime Web returns plain
79
- * numbers, which the wasm glue then rejects with "Cannot convert 1 to a BigInt". Accept number
80
- * arrays in `BigUint64Array.set`, which only ever threw for them before.
81
- */
82
- function allowNumberDims() {
83
- const set = BigUint64Array.prototype.set;
84
- BigUint64Array.prototype.set = function (src, offset) {
85
- set.call(this, Array.isArray(src) ? src.map((v) => BigInt(v)) : src, offset);
86
- };
87
- }
74
+ let initialized;
88
75
  /** Initialize the wasm module exactly once. */
89
- async function ensureInit(wasmUrl) {
90
- if (initialized)
91
- return;
92
- allowNumberDims();
93
- await init(wasmUrl ? { module_or_path: wasmUrl } : undefined);
94
- start();
95
- initialized = true;
76
+ function ensureInit(wasmUrl) {
77
+ initialized ?? (initialized = init(wasmUrl ? { module_or_path: wasmUrl } : undefined)
78
+ .then(() => start())
79
+ .catch((error) => {
80
+ initialized = undefined;
81
+ throw error;
82
+ }));
83
+ return initialized;
96
84
  }
97
85
  function isDrawable(input) {
98
- return (input instanceof ImageData ||
99
- input instanceof HTMLImageElement ||
100
- input instanceof HTMLCanvasElement ||
101
- input instanceof HTMLVideoElement ||
102
- input instanceof ImageBitmap);
86
+ return ((typeof ImageData !== "undefined" && input instanceof ImageData) ||
87
+ (typeof HTMLImageElement !== "undefined" && input instanceof HTMLImageElement) ||
88
+ (typeof HTMLCanvasElement !== "undefined" && input instanceof HTMLCanvasElement) ||
89
+ (typeof HTMLVideoElement !== "undefined" && input instanceof HTMLVideoElement) ||
90
+ (typeof OffscreenCanvas !== "undefined" && input instanceof OffscreenCanvas) ||
91
+ (typeof ImageBitmap !== "undefined" && input instanceof ImageBitmap));
103
92
  }
104
93
  /** Fetch a URL and throw a clear error naming `what` if the response is not OK. */
105
94
  async function fetchOk(url, what) {
@@ -121,15 +110,20 @@ async function toBytes(input, what) {
121
110
  }
122
111
  /** Read a drawable source as raw RGBA pixels (the fast path, no re-encoding). */
123
112
  function toImageData(input) {
124
- if (input instanceof ImageData) {
125
- return { data: new Uint8Array(input.data.buffer), width: input.width, height: input.height };
113
+ if (typeof ImageData !== "undefined" && input instanceof ImageData) {
114
+ return {
115
+ // Snapshot caller-owned pixels before a queued prediction can yield.
116
+ data: new Uint8Array(input.data),
117
+ width: input.width,
118
+ height: input.height,
119
+ };
126
120
  }
127
121
  let width;
128
122
  let height;
129
- if (input instanceof HTMLImageElement) {
123
+ if (typeof HTMLImageElement !== "undefined" && input instanceof HTMLImageElement) {
130
124
  [width, height] = [input.naturalWidth, input.naturalHeight];
131
125
  }
132
- else if (input instanceof HTMLVideoElement) {
126
+ else if (typeof HTMLVideoElement !== "undefined" && input instanceof HTMLVideoElement) {
133
127
  [width, height] = [input.videoWidth, input.videoHeight];
134
128
  }
135
129
  else {
@@ -139,7 +133,7 @@ function toImageData(input) {
139
133
  const ctx = get2d(canvas, { willReadFrequently: true });
140
134
  ctx.drawImage(input, 0, 0, width, height);
141
135
  const img = ctx.getImageData(0, 0, width, height);
142
- return { data: new Uint8Array(img.data.buffer), width, height };
136
+ return { data: new Uint8Array(img.data.buffer, img.data.byteOffset, img.data.byteLength), width, height };
143
137
  }
144
138
  function makeCanvas(width, height) {
145
139
  if (typeof OffscreenCanvas !== "undefined")
@@ -206,10 +200,13 @@ function ensureLiteRtRuntime(litert, wasmUrl) {
206
200
  litertInitUrl = wasmUrl;
207
201
  // Enable WASM multithreading when the page is cross-origin isolated (COOP/COEP
208
202
  // set, so SharedArrayBuffer is available); otherwise LiteRT.js runs single-
209
- // threaded. SIMD is detected by LiteRT itself. Isolation is a page-global
210
- // property, so this needs no per-load option.
211
- const threads = typeof crossOriginIsolated !== "undefined" && crossOriginIsolated;
212
- litertInit = litert.loadLiteRt(wasmUrl, { threads }).catch((e) => {
203
+ // threaded. LiteRT's threaded build also needs relaxed SIMD, which Safari lacks.
204
+ // Isolation is a page-global property, so this needs no per-load option.
205
+ const isolated = typeof crossOriginIsolated !== "undefined" && crossOriginIsolated;
206
+ litertInit = (async () => {
207
+ const threads = isolated && (await litert.supportsFeature("relaxedSimd"));
208
+ await litert.loadLiteRt(wasmUrl, { threads });
209
+ })().catch((e) => {
213
210
  litertInit = null; // let a later load retry if the first init failed
214
211
  litertInitUrl = null;
215
212
  throw e;
@@ -233,16 +230,22 @@ class LiteRtBackend {
233
230
  static async load(tflite, wasmUrl, accelerator) {
234
231
  const litert = await importLiteRt();
235
232
  await ensureLiteRtRuntime(litert, wasmUrl);
233
+ let model;
236
234
  try {
237
- const model = await litert.loadAndCompile(tflite, { accelerator });
238
- return new LiteRtBackend(litert, model, accelerator);
235
+ model = await litert.loadAndCompile(tflite, { accelerator });
239
236
  }
240
237
  catch (e) {
241
238
  if (accelerator === "wasm")
242
239
  throw e;
243
- const model = await litert.loadAndCompile(tflite, { accelerator: "wasm" });
244
- return new LiteRtBackend(litert, model, "wasm");
240
+ model = await litert.loadAndCompile(tflite, { accelerator: "wasm" });
245
241
  }
242
+ // This runtime is loaded without JSPI. A partially delegated model needs it to
243
+ // switch between GPU and CPU, even when the browser itself supports JSPI.
244
+ if (model.options.accelerator === "webgpu" && !model.isFullyAccelerated) {
245
+ model.delete?.();
246
+ model = await litert.loadAndCompile(tflite, { accelerator: "wasm" });
247
+ }
248
+ return new LiteRtBackend(litert, model, model.options.accelerator);
246
249
  }
247
250
  /** Upload the input tensor, run, and read every output back to the CPU. */
248
251
  async run(input, shape) {
@@ -254,16 +257,15 @@ class LiteRtBackend {
254
257
  const tensors = await this.model.run(gpuIn);
255
258
  const outputs = [];
256
259
  const shapes = [];
257
- for (const t of tensors) {
258
- const host = await t.moveTo("wasm");
259
- // Copy out before deleting; toTypedArray() may view the freed buffer.
260
- outputs.push(new Float32Array(host.toTypedArray()));
260
+ for (const tensor of tensors) {
261
+ const host = await tensor.moveTo("wasm");
262
+ // LiteRT's toTypedArray() already copies the host data.
263
+ const data = host.toTypedArray();
264
+ outputs.push(data instanceof Float32Array ? data : new Float32Array(data));
261
265
  shapes.push(Array.from(host.type.layout.dimensions));
262
266
  host.delete?.();
263
- // moveTo("wasm") returns the same tensor when it is already on wasm; only
264
- // delete the original separately when it is a distinct GPU tensor.
265
- if (t !== host)
266
- t.delete?.();
267
+ if (tensor !== host)
268
+ tensor.delete?.();
267
269
  }
268
270
  return { outputs, shapes, inferenceMs: performance.now() - t0 };
269
271
  }
@@ -307,10 +309,6 @@ class LiteRtEngine {
307
309
  constructor(pipeline, backend) {
308
310
  this.pipeline = pipeline;
309
311
  this.backend = backend;
310
- // `YoloPipeline` keeps exactly one pending frame in wasm state between
311
- // `preprocess_rgba` and `postprocess`, so predictions must not interleave.
312
- // Serialize them: a new call waits for the in-flight one to finish.
313
- this.queue = Promise.resolve();
314
312
  }
315
313
  get task() {
316
314
  return this.pipeline.task;
@@ -323,33 +321,22 @@ class LiteRtEngine {
323
321
  get names() {
324
322
  return this.pipeline.names;
325
323
  }
326
- predictDrawable(data, width, height, p) {
327
- return this.serialize(() => this.runDrawable(data, width, height, p));
328
- }
329
324
  /** LiteRT takes raw pixels, so decode encoded inputs to RGBA in JS first. */
330
- predictEncoded(bytes, p) {
331
- return this.serialize(async () => {
332
- const bitmap = await createImageBitmap(new Blob([bytes]));
333
- try {
334
- const { data, width, height } = toImageData(bitmap);
335
- return await this.runDrawable(data, width, height, p);
336
- }
337
- finally {
338
- bitmap.close();
339
- }
340
- });
325
+ async predictEncoded(bytes, p) {
326
+ const bitmap = await createImageBitmap(new Blob([bytes]));
327
+ try {
328
+ const { data, width, height } = toImageData(bitmap);
329
+ return await this.predictDrawable(data, width, height, p);
330
+ }
331
+ finally {
332
+ bitmap.close();
333
+ }
341
334
  }
342
- async runDrawable(data, width, height, p) {
335
+ async predictDrawable(data, width, height, p) {
343
336
  const input = this.pipeline.preprocess_rgba(data, width, height);
344
337
  const { outputs, shapes, inferenceMs } = await this.backend.run(input, Array.from(this.pipeline.inputShape));
345
338
  return this.pipeline.postprocess(outputs, shapes.map((s) => new Uint32Array(s)), inferenceMs, p.conf, p.iou, p.classes, p.colormap, p.depthViz);
346
339
  }
347
- /** Chain `fn` after any in-flight prediction so wasm frame state is never shared. */
348
- serialize(fn) {
349
- const result = this.queue.then(fn, fn);
350
- this.queue = result.then(() => undefined, () => undefined);
351
- return result;
352
- }
353
340
  free() {
354
341
  this.pipeline.free();
355
342
  this.backend.free();
@@ -362,6 +349,8 @@ class LiteRtEngine {
362
349
  export class YOLO {
363
350
  constructor(engine) {
364
351
  this.engine = engine;
352
+ // The wasm models keep mutable per-frame state; run one prediction per model at a time.
353
+ this.queue = Promise.resolve();
365
354
  }
366
355
  /**
367
356
  * Load a model and initialize the inference backend.
@@ -391,25 +380,7 @@ export class YOLO {
391
380
  const wasmUrl = options?.litertWasmUrl ? options.litertWasmUrl.toString() : DEFAULT_LITERT_WASM;
392
381
  // Honor `device` including `"auto"`, which feature-detects WebGPU (so a
393
382
  // browser without it goes straight to wasm instead of a failed compile).
394
- let accelerator = (await resolveDevice(options?.device)) === "webgpu" ? "webgpu" : "wasm";
395
- // NMS-free exports (YOLO26, `nms=False`) do top-k selection with int64 + gather_nd ops the
396
- // LiteRT WebGPU delegate cannot run: it fails to invoke and returns zeros.
397
- // Force CPU/wasm so the model works. For WebGPU speed, re-export the model
398
- // with Ultralytics >=8.4.142 and `nms=None` for the one-to-many head (NMS in Rust).
399
- if (accelerator === "webgpu" && pipeline.end2end) {
400
- accelerator = "wasm";
401
- console.warn("LiteRT: this is an NMS-free model; its WebGPU delegate can't run the int64 ops, so it runs on CPU/wasm. Re-export with Ultralytics >=8.4.142 and `nms=None` for WebGPU.");
402
- }
403
- // RT-DETR's deformable-attention decoder reshapes to rank 5 and indexes with int64,
404
- // which the LiteRT WebGPU delegate rejects: Vulkan logs a RESHAPE error per offending
405
- // node and falls back per-op, Metal-3 fails the compile outright. `"auto"` therefore
406
- // goes straight to wasm and skips the noise and the wasted GPU compile. An explicit
407
- // `device: "webgpu"` is still honored, so this can be re-tested when the delegate
408
- // grows the missing ops, without patching the library.
409
- if (accelerator === "webgpu" && pipeline.rtdetr && options?.device !== "webgpu") {
410
- accelerator = "wasm";
411
- console.warn('LiteRT: RT-DETR\'s decoder uses rank-5 reshapes and int64 indices that the WebGPU delegate could not run on the drivers tested, so it runs on CPU/wasm. Pass device: "webgpu" to try it anyway.');
412
- }
383
+ const accelerator = (await resolveDevice(options?.device)) === "webgpu" ? "webgpu" : "wasm";
413
384
  const backend = await LiteRtBackend.load(tflite, wasmUrl, accelerator);
414
385
  // The compiled model outranks the metadata: `pipeline.inputShape` is what sizes the
415
386
  // input tensor below, so a stale `imgsz` would build one the model rejects.
@@ -436,7 +407,7 @@ export class YOLO {
436
407
  * Run inference on an image.
437
408
  *
438
409
  * Drawable sources (`ImageData`, `HTMLImageElement`, `HTMLCanvasElement`,
439
- * `HTMLVideoElement`, `ImageBitmap`) take a fast path that reads raw pixels
410
+ * `HTMLVideoElement`, `OffscreenCanvas`, `ImageBitmap`) take a fast path that reads raw pixels
440
411
  * with no re-encoding, ideal for webcam/video. URLs, `Blob`s, and raw bytes
441
412
  * are decoded (in wasm for `ort`, via a canvas for `litert`).
442
413
  *
@@ -445,20 +416,31 @@ export class YOLO {
445
416
  */
446
417
  async predict(image, options) {
447
418
  const p = {
448
- conf: options?.conf ?? DEFAULT_CONF,
449
- iou: options?.iou ?? DEFAULT_IOU,
419
+ // Unset thresholds fall back to the Rust `InferenceConfig` defaults.
420
+ conf: options?.conf,
421
+ iou: options?.iou,
450
422
  classes: options?.classes ? new Uint32Array(options.classes) : undefined,
451
423
  // Empty means "unset": the wasm side falls back to the Rust `Colormap`/`DepthViz`
452
424
  // defaults, so the default lives in exactly one place.
453
425
  colormap: options?.colormap ?? "",
454
426
  depthViz: options?.depthViz ?? "",
455
427
  };
428
+ let predict;
456
429
  if (isDrawable(image)) {
457
430
  const { data, width, height } = toImageData(image);
458
- return decodeResults(await this.engine.predictDrawable(data, width, height, p));
431
+ predict = () => this.engine.predictDrawable(data, width, height, p);
432
+ }
433
+ else {
434
+ const bytes = image instanceof Uint8Array
435
+ ? image.slice()
436
+ : image instanceof ArrayBuffer
437
+ ? new Uint8Array(image.slice(0))
438
+ : await toBytes(image, "image");
439
+ predict = () => this.engine.predictEncoded(bytes, p);
459
440
  }
460
- const bytes = await toBytes(image, "image");
461
- return decodeResults(await this.engine.predictEncoded(bytes, p));
441
+ const result = this.queue.then(async () => decodeResults(await predict()));
442
+ this.queue = result.then(() => undefined, () => undefined);
443
+ return result;
462
444
  }
463
445
  /** Release the underlying wasm model/engine. Call when you are done with it. */
464
446
  free() {
@@ -473,7 +455,7 @@ function textColorFor(hex) {
473
455
  const g = parseInt(hex.slice(3, 5), 16);
474
456
  const b = parseInt(hex.slice(5, 7), 16);
475
457
  // Perceived luminance (same threshold Ultralytics uses).
476
- return r * 0.299 + g * 0.587 + b * 0.114 > 140 ? "#000000" : "#FFFFFF";
458
+ return r * 0.299 + g * 0.587 + b * 0.114 > 150 ? "#000000" : "#FFFFFF";
477
459
  }
478
460
  /**
479
461
  * Draw inference results onto a canvas, on top of the source image.
@@ -528,17 +510,47 @@ export async function annotate(canvas, image, results, options) {
528
510
  ctx.lineWidth = lineWidth;
529
511
  ctx.font = font;
530
512
  ctx.textBaseline = "top";
513
+ ctx.textAlign = "left";
514
+ // Labels that may hold right-to-left text (Unicode's right-to-left blocks and controls) are
515
+ // drawn as the engine's bidi runs, each in its resolved direction, since Safari's canvas
516
+ // does not pair brackets in right-to-left text. Other labels read left to right as they are.
517
+ const rtlText = /[\u0590-\u08FF\u200F\u202B\u202E\u2067\u2068\uFB1D-\uFDFF\uFE70-\uFEFF\u{10800}-\u{10FFF}\u{1E800}-\u{1EFFF}]/u;
518
+ const names = [...results.boxes, ...results.obb].map((b) => b.name);
519
+ if (showLabels && names.concat(results.probs?.top5names ?? []).some((n) => rtlText.test(n))) {
520
+ await ensureInit(options?.wasmUrl);
521
+ }
522
+ // Class names repeat across labels, so each run's width is measured once per call.
523
+ const widths = new Map();
524
+ const layout = (text) => (rtlText.test(text) ? bidi_runs(text) : [text]).map((run) => {
525
+ const rtl = run.startsWith("\u202E");
526
+ let width = widths.get(run);
527
+ if (width === undefined) {
528
+ ctx.direction = rtl ? "rtl" : "ltr";
529
+ width = ctx.measureText(run).width;
530
+ widths.set(run, width);
531
+ }
532
+ return { text: run, rtl, width };
533
+ });
534
+ const runsWidth = (runs) => runs.reduce((sum, run) => sum + run.width, 0);
535
+ const fillText = (runs, x, y) => {
536
+ for (const run of runs) {
537
+ ctx.direction = run.rtl ? "rtl" : "ltr";
538
+ ctx.fillText(run.text, x, y);
539
+ x += run.width;
540
+ }
541
+ };
531
542
  const label = (text, x, y, color) => {
532
543
  if (!showLabels)
533
544
  return;
534
545
  const pad = Math.round(fontSize * 0.2);
535
- const w = ctx.measureText(text).width + pad * 2;
546
+ const runs = layout(text);
547
+ const w = runsWidth(runs) + pad * 2;
536
548
  const h = fontSize + pad * 2;
537
549
  const ly = Math.max(0, y - h);
538
550
  ctx.fillStyle = color;
539
551
  ctx.fillRect(x, ly, w, h);
540
552
  ctx.fillStyle = textColorFor(color);
541
- ctx.fillText(text, x + pad, ly + pad);
553
+ fillText(runs, x + pad, ly + pad);
542
554
  };
543
555
  // Axis-aligned boxes (detect / segment / pose).
544
556
  for (const b of results.boxes) {
@@ -612,15 +624,15 @@ export async function annotate(canvas, image, results, options) {
612
624
  // and Python renderers, which list the top classes rather than a single banner).
613
625
  if (results.probs && showLabels) {
614
626
  const { top5, top5conf, top5names } = results.probs;
615
- const lines = top5.map((_, i) => `${top5names[i] ?? top5[i]} ${top5conf[i].toFixed(2)}`);
627
+ const lines = top5.map((_, i) => layout(`${top5names[i] ?? top5[i]} ${top5conf[i].toFixed(2)}`));
616
628
  const pad = Math.round(fontSize * 0.3);
617
629
  const lineH = Math.round(fontSize * 1.25);
618
- const boxW = Math.max(...lines.map((t) => ctx.measureText(t).width)) + pad * 2;
630
+ const boxW = Math.max(...lines.map(runsWidth)) + pad * 2;
619
631
  const boxH = lines.length * lineH + pad * 2;
620
632
  ctx.fillStyle = "rgba(0, 0, 0, 0.4)";
621
633
  ctx.fillRect(pad, pad, boxW, boxH);
622
634
  ctx.fillStyle = "#ffffff";
623
- lines.forEach((t, i) => ctx.fillText(t, pad * 2, pad * 2 + i * lineH));
635
+ lines.forEach((t, i) => fillText(t, pad * 2, pad * 2 + i * lineH));
624
636
  }
625
637
  }
626
638
  /** Resolve any {@link ImageInput} to something `drawImage` accepts. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultralytics/yolo",
3
- "version": "0.0.54",
3
+ "version": "0.0.56",
4
4
  "description": "Run Ultralytics YOLO models in the browser on WebGPU (WebAssembly, ONNX Runtime Web via ort-web).",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
package/pkg/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "ultralytics-inference-web",
3
3
  "type": "module",
4
4
  "description": "Browser/WebAssembly bindings for ultralytics-inference (WebGPU via ort-web)",
5
- "version": "0.0.54",
5
+ "version": "0.0.56",
6
6
  "license": "AGPL-3.0",
7
7
  "repository": {
8
8
  "type": "git",
@@ -33,15 +33,15 @@ export class YoloModel {
33
33
  /**
34
34
  * Run inference on a single encoded image (JPEG or PNG bytes).
35
35
  *
36
- * `conf` and `iou` are the confidence and NMS IoU thresholds (pass the model
37
- * defaults 0.25 / 0.7 to match Ultralytics); `classes` optionally keeps only
36
+ * `conf` and `iou` are the confidence and NMS IoU thresholds (omit them for the
37
+ * Ultralytics defaults 0.25 / 0.7); `classes` optionally keeps only
38
38
  * the given class ids (for semantic, other pixels become background).
39
39
  * Returns a plain JS object whose shape mirrors the Ultralytics `Results` API.
40
40
  *
41
41
  * # Errors
42
42
  * Returns a JS error if the image cannot be decoded or inference fails.
43
43
  */
44
- predict(image: Uint8Array, conf: number, iou: number, classes: Uint32Array | null | undefined, colormap: string, depth_viz: string): Promise<any>;
44
+ predict(image: Uint8Array, conf: number | null | undefined, iou: number | null | undefined, classes: Uint32Array | null | undefined, colormap: string, depth_viz: string): Promise<any>;
45
45
  /**
46
46
  * Run inference on raw `RGBA` pixels (e.g. a canvas/webcam `ImageData`).
47
47
  *
@@ -51,7 +51,7 @@ export class YoloModel {
51
51
  * # Errors
52
52
  * Returns a JS error if the buffer size is wrong or inference fails.
53
53
  */
54
- predict_rgba(rgba: Uint8Array, width: number, height: number, conf: number, iou: number, classes: Uint32Array | null | undefined, colormap: string, depth_viz: string): Promise<any>;
54
+ predict_rgba(rgba: Uint8Array, width: number, height: number, conf: number | null | undefined, iou: number | null | undefined, classes: Uint32Array | null | undefined, colormap: string, depth_viz: string): Promise<any>;
55
55
  /**
56
56
  * The active device: `"webgpu"` or `"cpu"` (the fallback when WebGPU is
57
57
  * unavailable). Mirrors the native `Device` display.
@@ -110,7 +110,7 @@ export class YoloPipeline {
110
110
  * Returns a JS error if called before `preprocess_rgba`, if `shapes` does not
111
111
  * have one entry per output, or on serialization failure.
112
112
  */
113
- postprocess(outputs: Float32Array[], shapes: Uint32Array[], inference_ms: number, conf: number, iou: number, classes: Uint32Array | null | undefined, colormap: string, depth_viz: string): any;
113
+ postprocess(outputs: Float32Array[], shapes: Uint32Array[], inference_ms: number, conf: number | null | undefined, iou: number | null | undefined, classes: Uint32Array | null | undefined, colormap: string, depth_viz: string): any;
114
114
  /**
115
115
  * Preprocess raw RGBA pixels (e.g. a webcam `ImageData`) into the NCHW f32
116
116
  * input tensor an Ultralytics LiteRT/TFLite model expects, normalized to
@@ -139,12 +139,6 @@ export class YoloPipeline {
139
139
  * the metadata size in place.
140
140
  */
141
141
  setInputShape(shape: Int32Array): void;
142
- /**
143
- * Whether this is an NMS-free export, e.g. YOLO26 with `nms=False`. Its head runs
144
- * top-k selection with `int64`/`gather_nd` ops that the LiteRT WebGPU delegate
145
- * cannot execute, so such models must run on the CPU (wasm) accelerator.
146
- */
147
- readonly end2end: boolean;
148
142
  /**
149
143
  * The model input shape as `[1, 3, H, W]` (NCHW), for sizing the engine's
150
144
  * input tensor. Ultralytics LiteRT exports (`ai_edge_torch`) keep the native
@@ -158,18 +152,21 @@ export class YoloPipeline {
158
152
  * Returns a JS error only if serialization fails (not expected).
159
153
  */
160
154
  readonly names: any;
161
- /**
162
- * Whether this is an RT-DETR export. Its deformable-attention decoder reshapes to
163
- * rank 5 and indexes with `int64`, neither of which the LiteRT WebGPU delegate
164
- * supports, so such models must run on the CPU (wasm) accelerator.
165
- */
166
- readonly rtdetr: boolean;
167
155
  /**
168
156
  * The model's task (`"detect"`, `"segment"`, ...).
169
157
  */
170
158
  readonly task: string;
171
159
  }
172
160
 
161
+ /**
162
+ * Split a label into runs in left-to-right display order (Unicode bidi algorithm), each wrapped
163
+ * in a left-to-right or right-to-left override so canvas draws it in its resolved direction. The
164
+ * JS annotator draws runs one by one because Safari's canvas does not pair brackets in
165
+ * right-to-left text. Explicit embeddings, overrides and isolates are dropped, since the
166
+ * resolved levels already carry them.
167
+ */
168
+ export function bidi_runs(text: string): string[];
169
+
173
170
  /**
174
171
  * Return the Ultralytics pose skeleton + keypoint/limb colors (constant). The
175
172
  * JS annotator calls this once to color pose overlays from the shared palette.
@@ -190,6 +187,7 @@ export interface InitOutput {
190
187
  readonly memory: WebAssembly.Memory;
191
188
  readonly __wbg_yolomodel_free: (a: number, b: number) => void;
192
189
  readonly __wbg_yolopipeline_free: (a: number, b: number) => void;
190
+ readonly bidi_runs: (a: number, b: number, c: number) => void;
193
191
  readonly pose_palette: (a: number) => void;
194
192
  readonly start: () => void;
195
193
  readonly yolomodel_device: (a: number, b: number) => void;
@@ -198,19 +196,17 @@ export interface InitOutput {
198
196
  readonly yolomodel_predict: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => number;
199
197
  readonly yolomodel_predict_rgba: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number) => number;
200
198
  readonly yolomodel_task: (a: number, b: number) => void;
201
- readonly yolopipeline_end2end: (a: number) => number;
202
199
  readonly yolopipeline_inputShape: (a: number, b: number) => void;
203
200
  readonly yolopipeline_names: (a: number, b: number) => void;
204
201
  readonly yolopipeline_new: (a: number, b: number, c: number) => void;
205
202
  readonly yolopipeline_postprocess: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number) => void;
206
203
  readonly yolopipeline_preprocess_rgba: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
207
- readonly yolopipeline_rtdetr: (a: number) => number;
208
204
  readonly yolopipeline_setInputShape: (a: number, b: number, c: number) => void;
209
205
  readonly yolopipeline_task: (a: number, b: number) => void;
210
- readonly __wasm_bindgen_func_elem_1159: (a: number, b: number, c: number, d: number) => void;
211
- readonly __wasm_bindgen_func_elem_1159_20: (a: number, b: number, c: number, d: number) => void;
212
- readonly __wasm_bindgen_func_elem_1786: (a: number, b: number, c: number, d: number) => void;
213
- readonly __wasm_bindgen_func_elem_1810: (a: number, b: number, c: number, d: number) => void;
206
+ readonly __wasm_bindgen_func_elem_1216: (a: number, b: number, c: number, d: number) => void;
207
+ readonly __wasm_bindgen_func_elem_1847: (a: number, b: number, c: number, d: number) => void;
208
+ readonly __wasm_bindgen_func_elem_1871: (a: number, b: number, c: number, d: number) => void;
209
+ readonly __wasm_bindgen_func_elem_382: (a: number, b: number, c: number, d: number) => void;
214
210
  readonly __wbindgen_export: (a: number, b: number) => number;
215
211
  readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
216
212
  readonly __wbindgen_export3: (a: number) => void;
@@ -1,6 +1,6 @@
1
1
  /* @ts-self-types="./ultralytics_inference_web.d.ts" */
2
- import { initRuntime } from './snippets/ort-web-d1ef36df9bbdf0c7/_loader.js';
3
- import { trackSessionInit } from './snippets/ort-web-d1ef36df9bbdf0c7/_telemetry.js';
2
+ import { initRuntime } from './snippets/ort-web-d8e9a032d14319ec/_loader.js';
3
+ import { trackSessionInit } from './snippets/ort-web-d8e9a032d14319ec/_telemetry.js';
4
4
 
5
5
 
6
6
  /**
@@ -104,16 +104,16 @@ export class YoloModel {
104
104
  /**
105
105
  * Run inference on a single encoded image (JPEG or PNG bytes).
106
106
  *
107
- * `conf` and `iou` are the confidence and NMS IoU thresholds (pass the model
108
- * defaults 0.25 / 0.7 to match Ultralytics); `classes` optionally keeps only
107
+ * `conf` and `iou` are the confidence and NMS IoU thresholds (omit them for the
108
+ * Ultralytics defaults 0.25 / 0.7); `classes` optionally keeps only
109
109
  * the given class ids (for semantic, other pixels become background).
110
110
  * Returns a plain JS object whose shape mirrors the Ultralytics `Results` API.
111
111
  *
112
112
  * # Errors
113
113
  * Returns a JS error if the image cannot be decoded or inference fails.
114
114
  * @param {Uint8Array} image
115
- * @param {number} conf
116
- * @param {number} iou
115
+ * @param {number | null | undefined} conf
116
+ * @param {number | null | undefined} iou
117
117
  * @param {Uint32Array | null | undefined} classes
118
118
  * @param {string} colormap
119
119
  * @param {string} depth_viz
@@ -128,7 +128,7 @@ export class YoloModel {
128
128
  const len2 = WASM_VECTOR_LEN;
129
129
  const ptr3 = passStringToWasm0(depth_viz, wasm.__wbindgen_export, wasm.__wbindgen_export2);
130
130
  const len3 = WASM_VECTOR_LEN;
131
- const ret = wasm.yolomodel_predict(this.__wbg_ptr, ptr0, len0, conf, iou, ptr1, len1, ptr2, len2, ptr3, len3);
131
+ const ret = wasm.yolomodel_predict(this.__wbg_ptr, ptr0, len0, isLikeNone(conf) ? Number.MAX_SAFE_INTEGER : Math.fround(conf), isLikeNone(iou) ? Number.MAX_SAFE_INTEGER : Math.fround(iou), ptr1, len1, ptr2, len2, ptr3, len3);
132
132
  return takeObject(ret);
133
133
  }
134
134
  /**
@@ -142,8 +142,8 @@ export class YoloModel {
142
142
  * @param {Uint8Array} rgba
143
143
  * @param {number} width
144
144
  * @param {number} height
145
- * @param {number} conf
146
- * @param {number} iou
145
+ * @param {number | null | undefined} conf
146
+ * @param {number | null | undefined} iou
147
147
  * @param {Uint32Array | null | undefined} classes
148
148
  * @param {string} colormap
149
149
  * @param {string} depth_viz
@@ -158,7 +158,7 @@ export class YoloModel {
158
158
  const len2 = WASM_VECTOR_LEN;
159
159
  const ptr3 = passStringToWasm0(depth_viz, wasm.__wbindgen_export, wasm.__wbindgen_export2);
160
160
  const len3 = WASM_VECTOR_LEN;
161
- const ret = wasm.yolomodel_predict_rgba(this.__wbg_ptr, ptr0, len0, width, height, conf, iou, ptr1, len1, ptr2, len2, ptr3, len3);
161
+ const ret = wasm.yolomodel_predict_rgba(this.__wbg_ptr, ptr0, len0, width, height, isLikeNone(conf) ? Number.MAX_SAFE_INTEGER : Math.fround(conf), isLikeNone(iou) ? Number.MAX_SAFE_INTEGER : Math.fround(iou), ptr1, len1, ptr2, len2, ptr3, len3);
162
162
  return takeObject(ret);
163
163
  }
164
164
  /**
@@ -207,16 +207,6 @@ export class YoloPipeline {
207
207
  const ptr = this.__destroy_into_raw();
208
208
  wasm.__wbg_yolopipeline_free(ptr, 0);
209
209
  }
210
- /**
211
- * Whether this is an NMS-free export, e.g. YOLO26 with `nms=False`. Its head runs
212
- * top-k selection with `int64`/`gather_nd` ops that the LiteRT WebGPU delegate
213
- * cannot execute, so such models must run on the CPU (wasm) accelerator.
214
- * @returns {boolean}
215
- */
216
- get end2end() {
217
- const ret = wasm.yolopipeline_end2end(this.__wbg_ptr);
218
- return ret !== 0;
219
- }
220
210
  /**
221
211
  * The model input shape as `[1, 3, H, W]` (NCHW), for sizing the engine's
222
212
  * input tensor. Ultralytics LiteRT exports (`ai_edge_torch`) keep the native
@@ -304,8 +294,8 @@ export class YoloPipeline {
304
294
  * @param {Float32Array[]} outputs
305
295
  * @param {Uint32Array[]} shapes
306
296
  * @param {number} inference_ms
307
- * @param {number} conf
308
- * @param {number} iou
297
+ * @param {number | null | undefined} conf
298
+ * @param {number | null | undefined} iou
309
299
  * @param {Uint32Array | null | undefined} classes
310
300
  * @param {string} colormap
311
301
  * @param {string} depth_viz
@@ -324,7 +314,7 @@ export class YoloPipeline {
324
314
  const len3 = WASM_VECTOR_LEN;
325
315
  const ptr4 = passStringToWasm0(depth_viz, wasm.__wbindgen_export, wasm.__wbindgen_export2);
326
316
  const len4 = WASM_VECTOR_LEN;
327
- wasm.yolopipeline_postprocess(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, inference_ms, conf, iou, ptr2, len2, ptr3, len3, ptr4, len4);
317
+ wasm.yolopipeline_postprocess(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, inference_ms, isLikeNone(conf) ? Number.MAX_SAFE_INTEGER : Math.fround(conf), isLikeNone(iou) ? Number.MAX_SAFE_INTEGER : Math.fround(iou), ptr2, len2, ptr3, len3, ptr4, len4);
328
318
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
329
319
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
330
320
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -369,16 +359,6 @@ export class YoloPipeline {
369
359
  wasm.__wbindgen_add_to_stack_pointer(16);
370
360
  }
371
361
  }
372
- /**
373
- * Whether this is an RT-DETR export. Its deformable-attention decoder reshapes to
374
- * rank 5 and indexes with `int64`, neither of which the LiteRT WebGPU delegate
375
- * supports, so such models must run on the CPU (wasm) accelerator.
376
- * @returns {boolean}
377
- */
378
- get rtdetr() {
379
- const ret = wasm.yolopipeline_rtdetr(this.__wbg_ptr);
380
- return ret !== 0;
381
- }
382
362
  /**
383
363
  * Adopt the input shape the engine reports for the compiled model.
384
364
  *
@@ -422,6 +402,31 @@ export class YoloPipeline {
422
402
  }
423
403
  if (Symbol.dispose) YoloPipeline.prototype[Symbol.dispose] = YoloPipeline.prototype.free;
424
404
 
405
+ /**
406
+ * Split a label into runs in left-to-right display order (Unicode bidi algorithm), each wrapped
407
+ * in a left-to-right or right-to-left override so canvas draws it in its resolved direction. The
408
+ * JS annotator draws runs one by one because Safari's canvas does not pair brackets in
409
+ * right-to-left text. Explicit embeddings, overrides and isolates are dropped, since the
410
+ * resolved levels already carry them.
411
+ * @param {string} text
412
+ * @returns {string[]}
413
+ */
414
+ export function bidi_runs(text) {
415
+ try {
416
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
417
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
418
+ const len0 = WASM_VECTOR_LEN;
419
+ wasm.bidi_runs(retptr, ptr0, len0);
420
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
421
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
422
+ var v2 = getArrayJsValueFromWasm0(r0, r1);
423
+ wasm.__wbindgen_export4(r0, r1 * 4, 4);
424
+ return v2;
425
+ } finally {
426
+ wasm.__wbindgen_add_to_stack_pointer(16);
427
+ }
428
+ }
429
+
425
430
  /**
426
431
  * Return the Ultralytics pose skeleton + keypoint/limb colors (constant). The
427
432
  * JS annotator calls this once to color pose overlays from the shared palette.
@@ -557,25 +562,28 @@ function __wbg_get_imports() {
557
562
  const ret = getObject(arg0).call(getObject(arg1));
558
563
  return addHeapObject(ret);
559
564
  }, arguments); },
560
- __wbg_create_92add3f2dd5e9fec: function() { return handleError(function (arg0, arg1, arg2) {
565
+ __wbg_create_07db378e252080ec: function() { return handleError(function (arg0, arg1, arg2) {
561
566
  const ret = ort.InferenceSession.create(getStringFromWasm0(arg0, arg1), takeObject(arg2));
562
567
  return addHeapObject(ret);
563
568
  }, arguments); },
564
- __wbg_create_c3bda381e473821b: function() { return handleError(function (arg0, arg1) {
569
+ __wbg_create_573b47018e76ad99: function() { return handleError(function (arg0, arg1) {
565
570
  const ret = ort.InferenceSession.create(getObject(arg0), takeObject(arg1));
566
571
  return addHeapObject(ret);
567
572
  }, arguments); },
568
- __wbg_data_7ea15a3ce3038789: function() { return handleError(function (arg0) {
573
+ __wbg_data_e242aa3d2f3b3ce2: function() { return handleError(function (arg0) {
569
574
  const ret = getObject(arg0).data;
570
575
  return addHeapObject(ret);
571
576
  }, arguments); },
572
- __wbg_dims_ad4921ea2a0e2688: function(arg0, arg1) {
577
+ __wbg_dims_b9c966d20c2a4d79: function(arg0, arg1) {
573
578
  const ret = getObject(arg1).dims;
574
- const ptr1 = passArray64ToWasm0(ret, wasm.__wbindgen_export);
579
+ const ptr1 = passArrayF64ToWasm0(ret, wasm.__wbindgen_export);
575
580
  const len1 = WASM_VECTOR_LEN;
576
581
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
577
582
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
578
583
  },
584
+ __wbg_dispose_17a92fe091ac456b: function() { return handleError(function (arg0) {
585
+ getObject(arg0).dispose();
586
+ }, arguments); },
579
587
  __wbg_done_b41a1d26cdb37fb6: function(arg0) {
580
588
  const ret = getObject(arg0).done;
581
589
  return ret;
@@ -599,7 +607,7 @@ function __wbg_get_imports() {
599
607
  const ret = Array.from(getObject(arg0));
600
608
  return addHeapObject(ret);
601
609
  },
602
- __wbg_getData_636da3f54c76e83d: function() { return handleError(function (arg0) {
610
+ __wbg_getData_ae0be7023598e2c2: function() { return handleError(function (arg0) {
603
611
  const ret = getObject(arg0).getData();
604
612
  return addHeapObject(ret);
605
613
  }, arguments); },
@@ -623,18 +631,18 @@ function __wbg_get_imports() {
623
631
  const ret = getObject(arg0)[getObject(arg1)];
624
632
  return addHeapObject(ret);
625
633
  },
626
- __wbg_initRuntime_b299fae72b0dc4e0: function() { return handleError(function (arg0, arg1) {
634
+ __wbg_initRuntime_cfc81535b182a89a: function() { return handleError(function (arg0, arg1) {
627
635
  const ret = initRuntime(arg0, takeObject(arg1));
628
636
  return addHeapObject(ret);
629
637
  }, arguments); },
630
- __wbg_inputMetadata_d393d214fc106b6b: function(arg0, arg1) {
638
+ __wbg_inputMetadata_b0480cebe7a00667: function(arg0, arg1) {
631
639
  const ret = getObject(arg1).inputMetadata;
632
640
  const ptr1 = passArrayJsValueToWasm0(ret, wasm.__wbindgen_export);
633
641
  const len1 = WASM_VECTOR_LEN;
634
642
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
635
643
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
636
644
  },
637
- __wbg_inputNames_724b40f0a2d8fba4: function(arg0, arg1) {
645
+ __wbg_inputNames_2897599e914f9792: function(arg0, arg1) {
638
646
  const ret = getObject(arg1).inputNames;
639
647
  const ptr1 = passArrayJsValueToWasm0(ret, wasm.__wbindgen_export);
640
648
  const len1 = WASM_VECTOR_LEN;
@@ -661,20 +669,20 @@ function __wbg_get_imports() {
661
669
  const ret = result;
662
670
  return ret;
663
671
  },
664
- __wbg_instanceof_Uint8Array_828cef2aaacafc31: function(arg0) {
672
+ __wbg_instanceof_Performance_cbec0dbedaa91be1: function(arg0) {
665
673
  let result;
666
674
  try {
667
- result = getObject(arg0) instanceof Uint8Array;
675
+ result = getObject(arg0) instanceof Performance;
668
676
  } catch (_) {
669
677
  result = false;
670
678
  }
671
679
  const ret = result;
672
680
  return ret;
673
681
  },
674
- __wbg_instanceof_Window_82d71df4eddf88bc: function(arg0) {
682
+ __wbg_instanceof_Uint8Array_828cef2aaacafc31: function(arg0) {
675
683
  let result;
676
684
  try {
677
- result = getObject(arg0) instanceof Window;
685
+ result = getObject(arg0) instanceof Uint8Array;
678
686
  } catch (_) {
679
687
  result = false;
680
688
  }
@@ -709,10 +717,14 @@ function __wbg_get_imports() {
709
717
  const ret = getObject(arg0).length;
710
718
  return ret;
711
719
  },
712
- __wbg_location_348911e2e503af1d: function(arg0) {
720
+ __wbg_location_02e5bf0e6b80a0f5: function(arg0) {
713
721
  const ret = getObject(arg0).location;
714
722
  return (__wbindgen_enum_DataLocation.indexOf(ret) + 1 || 7) - 1;
715
723
  },
724
+ __wbg_message_5f8387f0c32b90a7: function(arg0) {
725
+ const ret = getObject(arg0).message;
726
+ return addHeapObject(ret);
727
+ },
716
728
  __wbg_new_1dbf7428bba60a42: function(arg0) {
717
729
  const ret = new Uint8Array(getObject(arg0));
718
730
  return addHeapObject(ret);
@@ -733,10 +745,14 @@ function __wbg_get_imports() {
733
745
  const ret = new Array();
734
746
  return addHeapObject(ret);
735
747
  },
736
- __wbg_new_from_buffer_raw_1a36905fc3da3c96: function() { return handleError(function (arg0, arg1, arg2) {
748
+ __wbg_new_from_buffer_raw_eb33cdffdf32a27b: function() { return handleError(function (arg0, arg1, arg2) {
737
749
  const ret = new ort.Tensor(__wbindgen_enum_DataType[arg0], takeObject(arg1), takeObject(arg2));
738
750
  return addHeapObject(ret);
739
751
  }, arguments); },
752
+ __wbg_new_from_slice_9a868026ffa4208a: function(arg0, arg1) {
753
+ const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
754
+ return addHeapObject(ret);
755
+ },
740
756
  __wbg_new_from_slice_ca6ad97db1f4779a: function(arg0, arg1) {
741
757
  const ret = new Float32Array(getArrayF32FromWasm0(arg0, arg1));
742
758
  return addHeapObject(ret);
@@ -748,7 +764,7 @@ function __wbg_get_imports() {
748
764
  const a = state0.a;
749
765
  state0.a = 0;
750
766
  try {
751
- return __wasm_bindgen_func_elem_1810(a, state0.b, arg0, arg1);
767
+ return __wasm_bindgen_func_elem_1871(a, state0.b, arg0, arg1);
752
768
  } finally {
753
769
  state0.a = a;
754
770
  }
@@ -759,48 +775,44 @@ function __wbg_get_imports() {
759
775
  state0.a = 0;
760
776
  }
761
777
  },
762
- __wbg_new_with_byte_offset_and_length_2f5d7fc2a828b74d: function(arg0, arg1, arg2) {
763
- const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
778
+ __wbg_new_with_byte_offset_and_length_1dc9f6fbbe046da6: function(arg0, arg1, arg2) {
779
+ const ret = new Uint16Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
764
780
  return addHeapObject(ret);
765
781
  },
766
- __wbg_new_with_length_10ec131ed0376a89: function(arg0) {
767
- const ret = new Int8Array(arg0 >>> 0);
768
- return addHeapObject(ret);
769
- },
770
- __wbg_new_with_length_1135aa9e3c0fb17c: function(arg0) {
771
- const ret = new BigUint64Array(arg0 >>> 0);
782
+ __wbg_new_with_byte_offset_and_length_2f5d7fc2a828b74d: function(arg0, arg1, arg2) {
783
+ const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
772
784
  return addHeapObject(ret);
773
785
  },
774
- __wbg_new_with_length_178f83910c35a379: function(arg0) {
775
- const ret = new BigInt64Array(arg0 >>> 0);
786
+ __wbg_new_with_byte_offset_and_length_40c170286adc9005: function(arg0, arg1, arg2) {
787
+ const ret = new Float32Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
776
788
  return addHeapObject(ret);
777
789
  },
778
- __wbg_new_with_length_31d0d732d07f3195: function(arg0) {
779
- const ret = new Uint32Array(arg0 >>> 0);
790
+ __wbg_new_with_byte_offset_and_length_6e8c68600a3ecb84: function(arg0, arg1, arg2) {
791
+ const ret = new BigUint64Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
780
792
  return addHeapObject(ret);
781
793
  },
782
- __wbg_new_with_length_3827645dc5adb679: function(arg0) {
783
- const ret = new Float64Array(arg0 >>> 0);
794
+ __wbg_new_with_byte_offset_and_length_820ea3ecbd1a4828: function(arg0, arg1, arg2) {
795
+ const ret = new Int16Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
784
796
  return addHeapObject(ret);
785
797
  },
786
- __wbg_new_with_length_3da0ad195f6f63ba: function(arg0) {
787
- const ret = new Uint8Array(arg0 >>> 0);
798
+ __wbg_new_with_byte_offset_and_length_915c5de4270ab7e5: function(arg0, arg1, arg2) {
799
+ const ret = new Int8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
788
800
  return addHeapObject(ret);
789
801
  },
790
- __wbg_new_with_length_42910c27ec097fc3: function(arg0) {
791
- const ret = new Int32Array(arg0 >>> 0);
802
+ __wbg_new_with_byte_offset_and_length_b93e61c4e9440336: function(arg0, arg1, arg2) {
803
+ const ret = new Int32Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
792
804
  return addHeapObject(ret);
793
805
  },
794
- __wbg_new_with_length_6b2193ba95fe514b: function(arg0) {
795
- const ret = new Uint16Array(arg0 >>> 0);
806
+ __wbg_new_with_byte_offset_and_length_bf3e693fe2fffb6f: function(arg0, arg1, arg2) {
807
+ const ret = new Uint32Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
796
808
  return addHeapObject(ret);
797
809
  },
798
- __wbg_new_with_length_a29f4581839a9ad6: function(arg0) {
799
- const ret = new Int16Array(arg0 >>> 0);
810
+ __wbg_new_with_byte_offset_and_length_c14d867a5878f875: function(arg0, arg1, arg2) {
811
+ const ret = new BigInt64Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
800
812
  return addHeapObject(ret);
801
813
  },
802
- __wbg_new_with_length_cc0362bfe8499e5a: function(arg0) {
803
- const ret = new Float32Array(arg0 >>> 0);
814
+ __wbg_new_with_byte_offset_and_length_edf873b0b3173456: function(arg0, arg1, arg2) {
815
+ const ret = new Float64Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
804
816
  return addHeapObject(ret);
805
817
  },
806
818
  __wbg_next_33784799010f1bbe: function(arg0) {
@@ -815,14 +827,14 @@ function __wbg_get_imports() {
815
827
  const ret = getObject(arg0).now();
816
828
  return ret;
817
829
  },
818
- __wbg_outputMetadata_7300f513b14cec51: function(arg0, arg1) {
830
+ __wbg_outputMetadata_d74fba311b0cce30: function(arg0, arg1) {
819
831
  const ret = getObject(arg1).outputMetadata;
820
832
  const ptr1 = passArrayJsValueToWasm0(ret, wasm.__wbindgen_export);
821
833
  const len1 = WASM_VECTOR_LEN;
822
834
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
823
835
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
824
836
  },
825
- __wbg_outputNames_9d56e41945ee91d5: function(arg0, arg1) {
837
+ __wbg_outputNames_26deb7d052bac410: function(arg0, arg1) {
826
838
  const ret = getObject(arg1).outputNames;
827
839
  const ptr1 = passArrayJsValueToWasm0(ret, wasm.__wbindgen_export);
828
840
  const len1 = WASM_VECTOR_LEN;
@@ -833,10 +845,6 @@ function __wbg_get_imports() {
833
845
  const ret = Reflect.ownKeys(getObject(arg0));
834
846
  return addHeapObject(ret);
835
847
  }, arguments); },
836
- __wbg_performance_d0d7b03fc649b694: function(arg0) {
837
- const ret = getObject(arg0).performance;
838
- return isLikeNone(ret) ? 0 : addHeapObject(ret);
839
- },
840
848
  __wbg_prototypesetcall_06eb15da165dee8f: function(arg0, arg1, arg2) {
841
849
  Uint32Array.prototype.set.call(getArrayU32FromWasm0(arg0, arg1), getObject(arg2));
842
850
  },
@@ -857,18 +865,25 @@ function __wbg_get_imports() {
857
865
  __wbg_queueMicrotask_a72f977e97f23c5f: function(arg0) {
858
866
  queueMicrotask(getObject(arg0));
859
867
  },
868
+ __wbg_release_0dd02e33b7cd324c: function() { return handleError(function (arg0) {
869
+ const ret = getObject(arg0).release();
870
+ return addHeapObject(ret);
871
+ }, arguments); },
860
872
  __wbg_resolve_0076e10020304ede: function(arg0) {
861
873
  const ret = Promise.resolve(getObject(arg0));
862
874
  return addHeapObject(ret);
863
875
  },
864
- __wbg_run_9e09e7300abe14f9: function() { return handleError(function (arg0, arg1) {
865
- const ret = getObject(arg0).run(takeObject(arg1));
876
+ __wbg_run_2893666784c8891d: function() { return handleError(function (arg0, arg1, arg2, arg3) {
877
+ const ret = getObject(arg0).run(takeObject(arg1), takeObject(arg2), takeObject(arg3));
866
878
  return addHeapObject(ret);
867
879
  }, arguments); },
868
880
  __wbg_set_145a351398b48c65: function() { return handleError(function (arg0, arg1, arg2) {
869
881
  const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
870
882
  return ret;
871
883
  }, arguments); },
884
+ __wbg_set_34d08fd992d43d61: function(arg0, arg1, arg2) {
885
+ getObject(arg0).set(getObject(arg1), arg2 >>> 0);
886
+ },
872
887
  __wbg_set_575d3ddb70fe831d: function(arg0, arg1, arg2) {
873
888
  getObject(arg0).set(getArrayU8FromWasm0(arg1, arg2));
874
889
  },
@@ -924,11 +939,11 @@ function __wbg_get_imports() {
924
939
  const ret = getObject(arg0).toString();
925
940
  return addHeapObject(ret);
926
941
  },
927
- __wbg_trackSessionInit_802b774d44772d22: function() { return handleError(function (arg0, arg1) {
942
+ __wbg_trackSessionInit_b37a6598a5541f10: function() { return handleError(function (arg0, arg1) {
928
943
  const ret = trackSessionInit(getStringFromWasm0(arg0, arg1));
929
944
  return addHeapObject(ret);
930
945
  }, arguments); },
931
- __wbg_type_80ea00300eb18928: function(arg0) {
946
+ __wbg_type_e1fd5cc29b264a06: function(arg0) {
932
947
  const ret = getObject(arg0).type;
933
948
  return (__wbindgen_enum_DataType.indexOf(ret) + 1 || 16) - 1;
934
949
  },
@@ -941,18 +956,18 @@ function __wbg_get_imports() {
941
956
  return addHeapObject(ret);
942
957
  },
943
958
  __wbindgen_generic_0000000000000001: function(arg0, arg1) {
944
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 351, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
945
- const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_1159);
959
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 365, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
960
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_1216);
946
961
  return addHeapObject(ret);
947
962
  },
948
963
  __wbindgen_generic_0000000000000002: function(arg0, arg1) {
949
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 593, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
950
- const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_1786);
964
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 649, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
965
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_1847);
951
966
  return addHeapObject(ret);
952
967
  },
953
968
  __wbindgen_generic_0000000000000003: function(arg0, arg1) {
954
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("boolean")], shim_idx: 351, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
955
- const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_1159_20);
969
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("boolean")], shim_idx: 21, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
970
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_382);
956
971
  return addHeapObject(ret);
957
972
  },
958
973
  __wbindgen_generic_0000000000000004: function(arg0) {
@@ -1039,14 +1054,14 @@ function __wbg_get_imports() {
1039
1054
  };
1040
1055
  }
1041
1056
 
1042
- function __wasm_bindgen_func_elem_1810(arg0, arg1, arg2, arg3) {
1043
- wasm.__wasm_bindgen_func_elem_1810(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
1057
+ function __wasm_bindgen_func_elem_1871(arg0, arg1, arg2, arg3) {
1058
+ wasm.__wasm_bindgen_func_elem_1871(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
1044
1059
  }
1045
1060
 
1046
- function __wasm_bindgen_func_elem_1159(arg0, arg1, arg2) {
1061
+ function __wasm_bindgen_func_elem_1216(arg0, arg1, arg2) {
1047
1062
  try {
1048
1063
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1049
- wasm.__wasm_bindgen_func_elem_1159(retptr, arg0, arg1, addHeapObject(arg2));
1064
+ wasm.__wasm_bindgen_func_elem_1216(retptr, arg0, arg1, addHeapObject(arg2));
1050
1065
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1051
1066
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1052
1067
  if (r1) {
@@ -1057,10 +1072,10 @@ function __wasm_bindgen_func_elem_1159(arg0, arg1, arg2) {
1057
1072
  }
1058
1073
  }
1059
1074
 
1060
- function __wasm_bindgen_func_elem_1786(arg0, arg1, arg2) {
1075
+ function __wasm_bindgen_func_elem_1847(arg0, arg1, arg2) {
1061
1076
  try {
1062
1077
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1063
- wasm.__wasm_bindgen_func_elem_1786(retptr, arg0, arg1, addHeapObject(arg2));
1078
+ wasm.__wasm_bindgen_func_elem_1847(retptr, arg0, arg1, addHeapObject(arg2));
1064
1079
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1065
1080
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1066
1081
  if (r1) {
@@ -1071,10 +1086,10 @@ function __wasm_bindgen_func_elem_1786(arg0, arg1, arg2) {
1071
1086
  }
1072
1087
  }
1073
1088
 
1074
- function __wasm_bindgen_func_elem_1159_20(arg0, arg1, arg2) {
1089
+ function __wasm_bindgen_func_elem_382(arg0, arg1, arg2) {
1075
1090
  try {
1076
1091
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1077
- wasm.__wasm_bindgen_func_elem_1159_20(retptr, arg0, arg1, addHeapObject(arg2));
1092
+ wasm.__wasm_bindgen_func_elem_382(retptr, arg0, arg1, addHeapObject(arg2));
1078
1093
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1079
1094
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1080
1095
  if (r1) {
@@ -1211,6 +1226,16 @@ function getArrayI8FromWasm0(ptr, len) {
1211
1226
  return getInt8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
1212
1227
  }
1213
1228
 
1229
+ function getArrayJsValueFromWasm0(ptr, len) {
1230
+ ptr = ptr >>> 0;
1231
+ const mem = getDataViewMemory0();
1232
+ const result = [];
1233
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
1234
+ result.push(takeObject(mem.getUint32(i, true)));
1235
+ }
1236
+ return result;
1237
+ }
1238
+
1214
1239
  function getArrayU16FromWasm0(ptr, len) {
1215
1240
  ptr = ptr >>> 0;
1216
1241
  return getUint16ArrayMemory0().subarray(ptr / 2, ptr / 2 + len);
@@ -1377,16 +1402,16 @@ function passArray32ToWasm0(arg, malloc) {
1377
1402
  return ptr;
1378
1403
  }
1379
1404
 
1380
- function passArray64ToWasm0(arg, malloc) {
1381
- const ptr = malloc(arg.length * 8, 8) >>> 0;
1382
- getBigUint64ArrayMemory0().set(arg, ptr / 8);
1405
+ function passArray8ToWasm0(arg, malloc) {
1406
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
1407
+ getUint8ArrayMemory0().set(arg, ptr / 1);
1383
1408
  WASM_VECTOR_LEN = arg.length;
1384
1409
  return ptr;
1385
1410
  }
1386
1411
 
1387
- function passArray8ToWasm0(arg, malloc) {
1388
- const ptr = malloc(arg.length * 1, 1) >>> 0;
1389
- getUint8ArrayMemory0().set(arg, ptr / 1);
1412
+ function passArrayF64ToWasm0(arg, malloc) {
1413
+ const ptr = malloc(arg.length * 8, 8) >>> 0;
1414
+ getFloat64ArrayMemory0().set(arg, ptr / 8);
1390
1415
  WASM_VECTOR_LEN = arg.length;
1391
1416
  return ptr;
1392
1417
  }
@@ -3,6 +3,7 @@
3
3
  export const memory: WebAssembly.Memory;
4
4
  export const __wbg_yolomodel_free: (a: number, b: number) => void;
5
5
  export const __wbg_yolopipeline_free: (a: number, b: number) => void;
6
+ export const bidi_runs: (a: number, b: number, c: number) => void;
6
7
  export const pose_palette: (a: number) => void;
7
8
  export const start: () => void;
8
9
  export const yolomodel_device: (a: number, b: number) => void;
@@ -11,19 +12,17 @@ export const yolomodel_names: (a: number, b: number) => void;
11
12
  export const yolomodel_predict: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => number;
12
13
  export const yolomodel_predict_rgba: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number) => number;
13
14
  export const yolomodel_task: (a: number, b: number) => void;
14
- export const yolopipeline_end2end: (a: number) => number;
15
15
  export const yolopipeline_inputShape: (a: number, b: number) => void;
16
16
  export const yolopipeline_names: (a: number, b: number) => void;
17
17
  export const yolopipeline_new: (a: number, b: number, c: number) => void;
18
18
  export const yolopipeline_postprocess: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number) => void;
19
19
  export const yolopipeline_preprocess_rgba: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
20
- export const yolopipeline_rtdetr: (a: number) => number;
21
20
  export const yolopipeline_setInputShape: (a: number, b: number, c: number) => void;
22
21
  export const yolopipeline_task: (a: number, b: number) => void;
23
- export const __wasm_bindgen_func_elem_1159: (a: number, b: number, c: number, d: number) => void;
24
- export const __wasm_bindgen_func_elem_1159_20: (a: number, b: number, c: number, d: number) => void;
25
- export const __wasm_bindgen_func_elem_1786: (a: number, b: number, c: number, d: number) => void;
26
- export const __wasm_bindgen_func_elem_1810: (a: number, b: number, c: number, d: number) => void;
22
+ export const __wasm_bindgen_func_elem_1216: (a: number, b: number, c: number, d: number) => void;
23
+ export const __wasm_bindgen_func_elem_1847: (a: number, b: number, c: number, d: number) => void;
24
+ export const __wasm_bindgen_func_elem_1871: (a: number, b: number, c: number, d: number) => void;
25
+ export const __wasm_bindgen_func_elem_382: (a: number, b: number, c: number, d: number) => void;
27
26
  export const __wbindgen_export: (a: number, b: number) => number;
28
27
  export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
29
28
  export const __wbindgen_export3: (a: number) => void;