@ultralytics/yolo 0.0.53 → 0.0.55

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
@@ -174,6 +174,16 @@ const results = await model.predict(img, { colormap: "spectral", depthViz: "metr
174
174
  await annotate(canvas, img, results, { depthAlpha: 0.6 });
175
175
  ```
176
176
 
177
+ For pose, `annotate()` takes the Ultralytics `plot()` keypoint options: `keypointRadius` (default `5`),
178
+ `keypointThreshold`, `keypointLines`, `keypointColor`, and `skeleton` to connect the keypoints of a custom layout:
179
+
180
+ ```ts
181
+ await annotate(canvas, img, results, { keypointRadius: 4, skeleton: [[0, 1]] });
182
+ ```
183
+
184
+ `annotate()` also takes `lineWidth` and `font` to set the box width and label font, and `labels: false` or
185
+ `keypoints: false` to hide labels or keypoints.
186
+
177
187
  ## ⚙️ Requirements & Notes
178
188
 
179
189
  - **WebGPU** (Chrome/Edge, or Firefox with WebGPU enabled) from a **secure
@@ -183,14 +193,12 @@ await annotate(canvas, img, results, { depthAlpha: 0.6 });
183
193
  `YOLO.load("/models/yolo26n.onnx", { device: "webgpu" | "cpu" })` (default `"auto"`). If
184
194
  WebGPU cannot engage, the load falls back to CPU; `model.device` reports what
185
195
  actually ran.
196
+ - **Workers**: LiteRT image inputs and timing support worker globals; LiteRT's own worker asset
197
+ loading requirements still apply. The ONNX Runtime Web loader requires a browser window.
186
198
  - **RT-DETR**: supported for detection. An RT-DETR `.onnx` runs on WebGPU like any other
187
- model. An RT-DETR `.tflite` is routed to CPU/wasm under the default `device: "auto"`: its
188
- deformable-attention decoder reshapes to rank 5 and indexes with `int64`, which the LiteRT
189
- WebGPU delegate rejected on every driver tested (Linux/Vulkan and Apple Metal-3). An
190
- explicit `device: "webgpu"` is still attempted rather than overridden, so the delegate can
191
- be re-tested as it gains ops; on current drivers that attempt fails and LiteRT falls back
192
- to CPU/wasm, and `model.device` reports what ran. Export one yourself, since no RT-DETR
193
- ONNX or LiteRT model is published.
199
+ model. LiteRT models that cannot be fully delegated to WebGPU run on CPU/wasm;
200
+ `model.device` reports the selected device. Export an RT-DETR model yourself, since
201
+ no ONNX or LiteRT model is published.
194
202
  - **Model format**: export your model to ONNX with Ultralytics `>=8.4.142` so the metadata
195
203
  (task, class names, `imgsz`) is embedded:
196
204
 
@@ -211,6 +219,9 @@ await annotate(canvas, img, results, { depthAlpha: 0.6 });
211
219
  > `32`/`fp32` (default), `16`/`fp16`, and `8`/`int8`; the old flags still work
212
220
  > but emit a deprecation warning.
213
221
 
222
+ FP16 exports made on a GPU have float16 inputs and outputs. `YOLO.load` casts them to float32 at the graph edges,
223
+ so they run like FP16 exports made on a CPU.
224
+
214
225
  - **Runtime assets**: on first load, `ort-web` fetches the ONNX Runtime Web wasm
215
226
  bundle (~25 MB, browser-cached afterward) from `cdn.pyke.io`. If you set a
216
227
  Content-Security-Policy, allow that origin in `script-src`/`connect-src`. To
@@ -220,7 +231,8 @@ await annotate(canvas, img, results, { depthAlpha: 0.6 });
220
231
  ```
221
232
  The folder must contain the ONNX Runtime Web entry scripts (`ort.webgpu.min.js`
222
233
  and `ort.wasm.min.js` for the CPU fallback) plus the
223
- `ort-wasm-simd-threaded.{jsep,asyncify,}.{mjs,wasm}` binaries.
234
+ `ort-wasm-simd-threaded.{jsep,asyncify,}.{mjs,wasm}` binaries. If your bundler does not serve this package's
235
+ own `ultralytics_inference_web_bg.wasm`, pass its URL as `wasmUrl`.
224
236
  - **Telemetry**: `ort-web` can report the page domain to pyke on first session
225
237
  creation. This package turns that off, so nothing is sent. See the
226
238
  [ort-web docs](https://ort.pyke.io/backends/web) for what it would send.
@@ -288,19 +300,14 @@ Notes:
288
300
  embedded metadata) ships in
289
301
  [v8.4.83](https://github.com/ultralytics/ultralytics/releases/tag/v8.4.83) and
290
302
  later. Earlier versions emit the legacy TFLite format and won't load here.
291
- - **Keep the one-to-many head for WebGPU** (`nms=None`): the NMS-free YOLO26 head, exported
292
- with `nms=False`, has `int64` / `gather_nd` ops the LiteRT **WebGPU** delegate cannot
293
- run, so those exports fall back to CPU/wasm. Use Ultralytics `>=8.4.142` for this recipe; it exports
294
- the one-to-many head by default, so NMS runs in this package's Rust and inference stays
295
- on WebGPU:
303
+ - **NMS-free models**: recent YOLO26 LiteRT exports use GPU-compatible operators. Older
304
+ exports contain operations that may prevent full WebGPU delegation; those run on CPU/wasm.
305
+ Alternatively, export the one-to-many head to run NMS in Rust:
296
306
 
297
307
  ```bash
298
308
  yolo export model=yolo26n.pt format=litert nms=None
299
309
  ```
300
310
 
301
- If you load an NMS-free `.tflite`, the backend auto-switches it to wasm
302
- (slower) and logs a warning rather than returning empty results.
303
-
304
311
  - **Tasks**: detect, segment, semantic, depth, classify, pose, and obb are all supported.
305
312
  - **Cross-origin isolation**: LiteRT's threaded wasm wants `SharedArrayBuffer`,
306
313
  so serve with `Cross-Origin-Opener-Policy: same-origin` and
@@ -322,8 +329,7 @@ ONNX Runtime Web (`.onnx`):
322
329
 
323
330
  Apple M4, Chrome 153, `@ultralytics/yolo` 0.0.48 (ONNX Runtime Web 1.27, LiteRT.js 2.5.3). FP32 640×640 models
324
331
  exported with Ultralytics 8.4.163 (`nms=None`), cycling through the 128 COCO128 images after warmup (128 timed runs on
325
- WebGPU, 50 on CPU). NMS-free exports (`nms=False`) run at the same speed on ONNX Runtime Web, but LiteRT.js falls back
326
- to CPU/wasm for them, so keep `nms=None` for WebGPU.
332
+ WebGPU, 50 on CPU). Recent NMS-free LiteRT exports (`nms=False`) can also run on WebGPU.
327
333
 
328
334
  ## 🔨 Building From Source
329
335
 
package/README.zh-CN.md CHANGED
@@ -167,6 +167,16 @@ const results = await model.predict(img, { colormap: "spectral", depthViz: "metr
167
167
  await annotate(canvas, img, results, { depthAlpha: 0.6 });
168
168
  ```
169
169
 
170
+ 对于 pose 任务,`annotate()` 接受 Ultralytics `plot()` 的关键点选项:`keypointRadius`(默认 `5`)、
171
+ `keypointThreshold`、`keypointLines`、`keypointColor`,以及用于连接自定义布局关键点的 `skeleton`:
172
+
173
+ ```ts
174
+ await annotate(canvas, img, results, { keypointRadius: 4, skeleton: [[0, 1]] });
175
+ ```
176
+
177
+ `annotate()` 还接受 `lineWidth` 和 `font` 用于设置框线宽度和标签字体,以及 `labels: false` 或
178
+ `keypoints: false` 用于隐藏标签或关键点。
179
+
170
180
  ## ⚙️ 环境要求与注意事项
171
181
 
172
182
  - **WebGPU**(Chrome/Edge,或启用了 WebGPU 的 Firefox)配合**安全上下文**(`https://` 或
@@ -174,13 +184,11 @@ await annotate(canvas, img, results, { depthAlpha: 0.6 });
174
184
  `YOLO.load` 会自动回退到通用的 **CPU/wasm** 构建,随处可用。可通过
175
185
  `YOLO.load("/models/yolo26n.onnx", { device: "webgpu" | "cpu" })` 指定设备(默认 `"auto"`)。若 WebGPU
176
186
  无法启用,加载会回退到 CPU;`model.device` 会报告实际使用的设备。
177
- - **RT-DETR**:支持检测任务。RT-DETR 的 `.onnx` 可以像其他模型一样在 WebGPU 上运行;而
178
- RT-DETR 的 `.tflite` 在默认的 `device: "auto"` 下会被路由到 CPU/wasm,因为它的可变形注意力
179
- 解码器会 reshape 到 5 维并使用 `int64` 索引,目前测试过的所有驱动(Linux/Vulkan 与 Apple
180
- Metal-3)上 LiteRT 的 WebGPU delegate 都会拒绝这些算子。显式指定 `device: "webgpu"` 仍会
181
- 尝试使用 delegate,而不会被强制覆盖,便于在 delegate 补齐算子后重新测试;在当前驱动上该
182
- 尝试会失败,LiteRT 会回退到 CPU/wasm,`model.device` 会报告实际使用的设备。官方没有发布
183
- RT-DETR 的 ONNX 或 LiteRT 模型,需要自行导出。
187
+ - **Worker**:LiteRT 图像输入和计时支持 worker 环境,但仍须满足 LiteRT 自身的 worker 资源加载要求。
188
+ ONNX Runtime Web 加载器需要浏览器窗口。
189
+ - **RT-DETR**:支持检测任务。RT-DETR 的 `.onnx` 可以像其他模型一样在 WebGPU 上运行。
190
+ 无法完全委托给 WebGPU 的 LiteRT 模型会在 CPU/wasm 上运行,`model.device` 会报告实际使用的设备。
191
+ 官方没有发布 RT-DETR 的 ONNX 或 LiteRT 模型,需要自行导出。
184
192
  - **模型格式**:请使用 Ultralytics `>=8.4.142` 导出为 ONNX,以便元数据(任务、类别名称、`imgsz`)被嵌入模型:
185
193
 
186
194
  ```python
@@ -198,6 +206,9 @@ await annotate(canvas, img, results, { depthAlpha: 0.6 });
198
206
  > 对于 ONNX,支持的取值为 `32`/`fp32`(默认)、`16`/`fp16` 和 `8`/`int8`;旧标志
199
207
  > 仍可使用,但会触发弃用警告。
200
208
 
209
+ 在 GPU 上导出的 FP16 模型的输入和输出为 float16。`YOLO.load` 会在图的输入输出处将其转换为 float32,
210
+ 因此它们与在 CPU 上导出的 FP16 模型一样可以运行。
211
+
201
212
  - **运行时资源**:首次加载时,`ort-web` 会从 `cdn.pyke.io` 获取 ONNX Runtime Web 的 wasm 包
202
213
  (约 25 MB,之后由浏览器缓存)。如果你设置了 Content-Security-Policy,请在
203
214
  `script-src`/`connect-src` 中放行该源。若想完全避开 CDN,可自行托管运行时并指向它:
@@ -205,7 +216,8 @@ await annotate(canvas, img, results, { depthAlpha: 0.6 });
205
216
  const model = await YOLO.load("/models/yolo26n.onnx", { ortBaseUrl: "/ort/" });
206
217
  ```
207
218
  该目录需包含 ONNX Runtime Web 的入口脚本(`ort.webgpu.min.js`,以及 CPU 回退所需的
208
- `ort.wasm.min.js`)和 `ort-wasm-simd-threaded.{jsep,asyncify,}.{mjs,wasm}` 二进制文件。
219
+ `ort.wasm.min.js`)和 `ort-wasm-simd-threaded.{jsep,asyncify,}.{mjs,wasm}` 二进制文件。如果打包工具没有提供本包自带的
220
+ `ultralytics_inference_web_bg.wasm`,可通过 `wasmUrl` 传入其 URL。
209
221
  - **遥测**:`ort-web` 可以在首次创建会话时向 pyke 上报页面域名。本包已将其关闭,不会发送任何数据。
210
222
  上报内容见 [ort-web 文档](https://ort.pyke.io/backends/web)。
211
223
 
@@ -266,17 +278,13 @@ wasm 默认从 jsDelivr CDN 加载;向 `YOLO.load` 传入 `litertWasmUrl: "/li
266
278
  - **现有模型兼容性**:带内嵌元数据的单文件 LiteRT 导出自
267
279
  [v8.4.83](https://github.com/ultralytics/ultralytics/releases/tag/v8.4.83) 起提供。更早的版本
268
280
  会导出旧版 TFLite 格式,无法在这里加载。
269
- - **为 WebGPU 保留一对多检测头**(`nms=None`):以 `nms=False` 导出的 YOLO26 无 NMS 检测头包含
270
- `int64` / `gather_nd` 算子,无法在 LiteRT 的 **WebGPU** delegate 上运行,因此这类导出会
271
- 回退到 CPU/wasm。以下命令需要 Ultralytics `>=8.4.142`,默认导出一对多检测头,NMS 由本包的 Rust 代码执行,
272
- 推理得以保持在 WebGPU 上:
281
+ - **无 NMS 模型**:较新的 YOLO26 LiteRT 导出使用兼容 GPU 的算子。旧版导出可能包含无法完全委托给
282
+ WebGPU 的算子,此时模型会在 CPU/wasm 上运行。也可以导出一对多检测头,由 Rust 执行 NMS:
273
283
 
274
284
  ```bash
275
285
  yolo export model=yolo26n.pt format=litert nms=None
276
286
  ```
277
287
 
278
- 如果加载了无 NMS 的 `.tflite`,后端会自动切换到 wasm(较慢)并打印警告,而不是返回空结果。
279
-
280
288
  - **支持的任务**:detect、segment、semantic、depth、classify、pose 和 obb 均已支持。
281
289
  - **跨源隔离**:LiteRT 的多线程 wasm 需要 `SharedArrayBuffer`,因此请以
282
290
  `Cross-Origin-Opener-Policy: same-origin` 和 `Cross-Origin-Embedder-Policy: require-corp`
@@ -298,8 +306,7 @@ Web(`.onnx`):
298
306
 
299
307
  测试环境:Apple M4、Chrome 153、`@ultralytics/yolo` 0.0.48(ONNX Runtime Web 1.27、LiteRT.js 2.5.3)。模型为使用
300
308
  Ultralytics 8.4.163 导出的 FP32 640×640 模型(`nms=None`),预热后循环使用 COCO128 的 128 张图像(WebGPU 计时 128 次,CPU
301
- 计时 50 次)。无 NMS 导出(`nms=False`)在 ONNX Runtime Web 上速度相同,但 LiteRT.js 会回退到 CPU/wasm 运行,因此 WebGPU
302
- 请保持 `nms=None`。
309
+ 计时 50 次)。较新的无 NMS LiteRT 导出(`nms=False`)也可以在 WebGPU 上运行。
303
310
 
304
311
  ## 🔨 从源码构建
305
312
 
package/dist/index.d.ts CHANGED
@@ -143,6 +143,17 @@ export interface AnnotateOptions {
143
143
  keypoints?: boolean;
144
144
  /** Keypoint confidence threshold for drawing. Default `0.25` (matches Ultralytics). */
145
145
  keypointThreshold?: number;
146
+ /** Keypoint radius in pixels (`kpt_radius`). Default `5`, like Ultralytics. */
147
+ keypointRadius?: number;
148
+ /** Draw the lines between keypoints (`kpt_line`). Default `true`. */
149
+ keypointLines?: boolean;
150
+ /** One CSS color for every keypoint and line (`kpt_color`). Defaults to the palette. */
151
+ keypointColor?: string;
152
+ /**
153
+ * Pairs of keypoint indices to connect. Defaults to the human skeleton for 17-keypoint
154
+ * (COCO-Pose) models and no lines for other layouts, like Ultralytics.
155
+ */
156
+ skeleton?: Array<[number, number]>;
146
157
  /**
147
158
  * Blend opacity for the depth overlay, `0`..`1`. Default `0.6` (matches the native
148
159
  * annotator); `1` shows the raw colorized depth map, `0` shows only the source.
@@ -150,13 +161,14 @@ export interface AnnotateOptions {
150
161
  depthAlpha?: number;
151
162
  }
152
163
  /** Image-like inputs accepted by {@link YOLO.predict}. */
153
- export type ImageInput = string | URL | Blob | ArrayBuffer | Uint8Array | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap;
164
+ export type ImageInput = string | URL | Blob | ArrayBuffer | Uint8Array | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas | ImageBitmap;
154
165
  /**
155
166
  * A loaded YOLO model. Loading is asynchronous, so use {@link YOLO.load} instead
156
167
  * of a constructor.
157
168
  */
158
169
  export declare class YOLO {
159
170
  private readonly engine;
171
+ private queue;
160
172
  private constructor();
161
173
  /**
162
174
  * Load a model and initialize the inference backend.
@@ -182,7 +194,7 @@ export declare class YOLO {
182
194
  * Run inference on an image.
183
195
  *
184
196
  * Drawable sources (`ImageData`, `HTMLImageElement`, `HTMLCanvasElement`,
185
- * `HTMLVideoElement`, `ImageBitmap`) take a fast path that reads raw pixels
197
+ * `HTMLVideoElement`, `OffscreenCanvas`, `ImageBitmap`) take a fast path that reads raw pixels
186
198
  * with no re-encoding, ideal for webcam/video. URLs, `Blob`s, and raw bytes
187
199
  * are decoded (in wasm for `ort`, via a canvas for `litert`).
188
200
  *
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  // Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
2
2
  /**
3
- * Browser bindings for Ultralytics YOLO inference on WebGPU.
3
+ * Browser bindings for Ultralytics YOLO inference on WebGPU or CPU.
4
4
  *
5
5
  * Thin TypeScript wrapper around the WebAssembly module compiled from the
6
- * `ultralytics-inference` Rust crate. Inference runs on the GPU through ONNX
7
- * Runtime Web (bridged by `ort-web`); this module hides the wasm init, GPU
8
- * setup, and image encoding behind a small `YOLO` class:
6
+ * `ultralytics-inference` Rust crate. `.onnx` models run through ONNX Runtime Web
7
+ * (bridged by `ort-web`) and `.tflite` models through LiteRT.js; this module hides
8
+ * the wasm init, device setup, and image encoding behind a small `YOLO` class:
9
9
  *
10
10
  * ```ts
11
11
  * import { YOLO } from "@ultralytics/yolo";
@@ -73,33 +73,24 @@ function decodeResults(raw) {
73
73
  r.semantic_mask = sem && sem.length ? new Uint16Array(sem.buffer, sem.byteOffset, sem.length / 2) : undefined;
74
74
  return r;
75
75
  }
76
- let initialized = false;
76
+ let initialized;
77
77
  /** Initialize the wasm module exactly once. */
78
- /**
79
- * `ort-web` 0.4.0 reads tensor dims as 64-bit integers, but ONNX Runtime Web returns plain
80
- * numbers, which the wasm glue then rejects with "Cannot convert 1 to a BigInt". Accept number
81
- * arrays in `BigUint64Array.set`, which only ever threw for them before.
82
- */
83
- function allowNumberDims() {
84
- const set = BigUint64Array.prototype.set;
85
- BigUint64Array.prototype.set = function (src, offset) {
86
- set.call(this, Array.isArray(src) ? src.map((v) => BigInt(v)) : src, offset);
87
- };
88
- }
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;
78
+ function ensureInit(wasmUrl) {
79
+ initialized ?? (initialized = init(wasmUrl ? { module_or_path: wasmUrl } : undefined)
80
+ .then(() => start())
81
+ .catch((error) => {
82
+ initialized = undefined;
83
+ throw error;
84
+ }));
85
+ return initialized;
96
86
  }
97
87
  function isDrawable(input) {
98
- return (input instanceof ImageData ||
99
- input instanceof HTMLImageElement ||
100
- input instanceof HTMLCanvasElement ||
101
- input instanceof HTMLVideoElement ||
102
- input instanceof ImageBitmap);
88
+ return ((typeof ImageData !== "undefined" && input instanceof ImageData) ||
89
+ (typeof HTMLImageElement !== "undefined" && input instanceof HTMLImageElement) ||
90
+ (typeof HTMLCanvasElement !== "undefined" && input instanceof HTMLCanvasElement) ||
91
+ (typeof HTMLVideoElement !== "undefined" && input instanceof HTMLVideoElement) ||
92
+ (typeof OffscreenCanvas !== "undefined" && input instanceof OffscreenCanvas) ||
93
+ (typeof ImageBitmap !== "undefined" && input instanceof ImageBitmap));
103
94
  }
104
95
  /** Fetch a URL and throw a clear error naming `what` if the response is not OK. */
105
96
  async function fetchOk(url, what) {
@@ -121,15 +112,20 @@ async function toBytes(input, what) {
121
112
  }
122
113
  /** Read a drawable source as raw RGBA pixels (the fast path, no re-encoding). */
123
114
  function toImageData(input) {
124
- if (input instanceof ImageData) {
125
- return { data: new Uint8Array(input.data.buffer), width: input.width, height: input.height };
115
+ if (typeof ImageData !== "undefined" && input instanceof ImageData) {
116
+ return {
117
+ // Snapshot caller-owned pixels before a queued prediction can yield.
118
+ data: new Uint8Array(input.data),
119
+ width: input.width,
120
+ height: input.height,
121
+ };
126
122
  }
127
123
  let width;
128
124
  let height;
129
- if (input instanceof HTMLImageElement) {
125
+ if (typeof HTMLImageElement !== "undefined" && input instanceof HTMLImageElement) {
130
126
  [width, height] = [input.naturalWidth, input.naturalHeight];
131
127
  }
132
- else if (input instanceof HTMLVideoElement) {
128
+ else if (typeof HTMLVideoElement !== "undefined" && input instanceof HTMLVideoElement) {
133
129
  [width, height] = [input.videoWidth, input.videoHeight];
134
130
  }
135
131
  else {
@@ -139,7 +135,7 @@ function toImageData(input) {
139
135
  const ctx = get2d(canvas, { willReadFrequently: true });
140
136
  ctx.drawImage(input, 0, 0, width, height);
141
137
  const img = ctx.getImageData(0, 0, width, height);
142
- return { data: new Uint8Array(img.data.buffer), width, height };
138
+ return { data: new Uint8Array(img.data.buffer, img.data.byteOffset, img.data.byteLength), width, height };
143
139
  }
144
140
  function makeCanvas(width, height) {
145
141
  if (typeof OffscreenCanvas !== "undefined")
@@ -233,16 +229,22 @@ class LiteRtBackend {
233
229
  static async load(tflite, wasmUrl, accelerator) {
234
230
  const litert = await importLiteRt();
235
231
  await ensureLiteRtRuntime(litert, wasmUrl);
232
+ let model;
236
233
  try {
237
- const model = await litert.loadAndCompile(tflite, { accelerator });
238
- return new LiteRtBackend(litert, model, accelerator);
234
+ model = await litert.loadAndCompile(tflite, { accelerator });
239
235
  }
240
236
  catch (e) {
241
237
  if (accelerator === "wasm")
242
238
  throw e;
243
- const model = await litert.loadAndCompile(tflite, { accelerator: "wasm" });
244
- return new LiteRtBackend(litert, model, "wasm");
239
+ model = await litert.loadAndCompile(tflite, { accelerator: "wasm" });
245
240
  }
241
+ // This runtime is loaded without JSPI. A partially delegated model needs it to
242
+ // switch between GPU and CPU, even when the browser itself supports JSPI.
243
+ if (model.options.accelerator === "webgpu" && !model.isFullyAccelerated) {
244
+ model.delete?.();
245
+ model = await litert.loadAndCompile(tflite, { accelerator: "wasm" });
246
+ }
247
+ return new LiteRtBackend(litert, model, model.options.accelerator);
246
248
  }
247
249
  /** Upload the input tensor, run, and read every output back to the CPU. */
248
250
  async run(input, shape) {
@@ -254,16 +256,15 @@ class LiteRtBackend {
254
256
  const tensors = await this.model.run(gpuIn);
255
257
  const outputs = [];
256
258
  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()));
259
+ for (const tensor of tensors) {
260
+ const host = await tensor.moveTo("wasm");
261
+ // LiteRT's toTypedArray() already copies the host data.
262
+ const data = host.toTypedArray();
263
+ outputs.push(data instanceof Float32Array ? data : new Float32Array(data));
261
264
  shapes.push(Array.from(host.type.layout.dimensions));
262
265
  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?.();
266
+ if (tensor !== host)
267
+ tensor.delete?.();
267
268
  }
268
269
  return { outputs, shapes, inferenceMs: performance.now() - t0 };
269
270
  }
@@ -307,10 +308,6 @@ class LiteRtEngine {
307
308
  constructor(pipeline, backend) {
308
309
  this.pipeline = pipeline;
309
310
  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
311
  }
315
312
  get task() {
316
313
  return this.pipeline.task;
@@ -324,35 +321,23 @@ class LiteRtEngine {
324
321
  return this.pipeline.names;
325
322
  }
326
323
  predictDrawable(data, width, height, p) {
327
- return this.serialize(() => this.runDrawable(data, width, height, p));
324
+ return this.runDrawable(data, width, height, p);
328
325
  }
329
326
  /** 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
- });
327
+ async predictEncoded(bytes, p) {
328
+ const bitmap = await createImageBitmap(new Blob([bytes]));
329
+ try {
330
+ const { data, width, height } = toImageData(bitmap);
331
+ return await this.runDrawable(data, width, height, p);
332
+ }
333
+ finally {
334
+ bitmap.close();
335
+ }
341
336
  }
342
337
  async runDrawable(data, width, height, p) {
343
338
  const input = this.pipeline.preprocess_rgba(data, width, height);
344
339
  const { outputs, shapes, inferenceMs } = await this.backend.run(input, Array.from(this.pipeline.inputShape));
345
- // Flatten shapes as [rank, dims..., rank, dims...] for the wasm boundary.
346
- const flatShapes = [];
347
- for (const s of shapes)
348
- flatShapes.push(s.length, ...s);
349
- return this.pipeline.postprocess(outputs, new Uint32Array(flatShapes), inferenceMs, p.conf, p.iou, p.classes, p.colormap, p.depthViz);
350
- }
351
- /** Chain `fn` after any in-flight prediction so wasm frame state is never shared. */
352
- serialize(fn) {
353
- const result = this.queue.then(fn, fn);
354
- this.queue = result.then(() => undefined, () => undefined);
355
- return result;
340
+ return this.pipeline.postprocess(outputs, shapes.map((s) => new Uint32Array(s)), inferenceMs, p.conf, p.iou, p.classes, p.colormap, p.depthViz);
356
341
  }
357
342
  free() {
358
343
  this.pipeline.free();
@@ -366,6 +351,8 @@ class LiteRtEngine {
366
351
  export class YOLO {
367
352
  constructor(engine) {
368
353
  this.engine = engine;
354
+ // The wasm models keep mutable per-frame state; run one prediction per model at a time.
355
+ this.queue = Promise.resolve();
369
356
  }
370
357
  /**
371
358
  * Load a model and initialize the inference backend.
@@ -395,25 +382,7 @@ export class YOLO {
395
382
  const wasmUrl = options?.litertWasmUrl ? options.litertWasmUrl.toString() : DEFAULT_LITERT_WASM;
396
383
  // Honor `device` including `"auto"`, which feature-detects WebGPU (so a
397
384
  // browser without it goes straight to wasm instead of a failed compile).
398
- let accelerator = (await resolveDevice(options?.device)) === "webgpu" ? "webgpu" : "wasm";
399
- // NMS-free exports (YOLO26, `nms=False`) do top-k selection with int64 + gather_nd ops the
400
- // LiteRT WebGPU delegate cannot run: it fails to invoke and returns zeros.
401
- // Force CPU/wasm so the model works. For WebGPU speed, re-export the model
402
- // with Ultralytics >=8.4.142 and `nms=None` for the one-to-many head (NMS in Rust).
403
- if (accelerator === "webgpu" && pipeline.end2end) {
404
- accelerator = "wasm";
405
- 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.");
406
- }
407
- // RT-DETR's deformable-attention decoder reshapes to rank 5 and indexes with int64,
408
- // which the LiteRT WebGPU delegate rejects: Vulkan logs a RESHAPE error per offending
409
- // node and falls back per-op, Metal-3 fails the compile outright. `"auto"` therefore
410
- // goes straight to wasm and skips the noise and the wasted GPU compile. An explicit
411
- // `device: "webgpu"` is still honored, so this can be re-tested when the delegate
412
- // grows the missing ops, without patching the library.
413
- if (accelerator === "webgpu" && pipeline.rtdetr && options?.device !== "webgpu") {
414
- accelerator = "wasm";
415
- 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.');
416
- }
385
+ const accelerator = (await resolveDevice(options?.device)) === "webgpu" ? "webgpu" : "wasm";
417
386
  const backend = await LiteRtBackend.load(tflite, wasmUrl, accelerator);
418
387
  // The compiled model outranks the metadata: `pipeline.inputShape` is what sizes the
419
388
  // input tensor below, so a stale `imgsz` would build one the model rejects.
@@ -440,7 +409,7 @@ export class YOLO {
440
409
  * Run inference on an image.
441
410
  *
442
411
  * Drawable sources (`ImageData`, `HTMLImageElement`, `HTMLCanvasElement`,
443
- * `HTMLVideoElement`, `ImageBitmap`) take a fast path that reads raw pixels
412
+ * `HTMLVideoElement`, `OffscreenCanvas`, `ImageBitmap`) take a fast path that reads raw pixels
444
413
  * with no re-encoding, ideal for webcam/video. URLs, `Blob`s, and raw bytes
445
414
  * are decoded (in wasm for `ort`, via a canvas for `litert`).
446
415
  *
@@ -457,12 +426,22 @@ export class YOLO {
457
426
  colormap: options?.colormap ?? "",
458
427
  depthViz: options?.depthViz ?? "",
459
428
  };
429
+ let predict;
460
430
  if (isDrawable(image)) {
461
431
  const { data, width, height } = toImageData(image);
462
- return decodeResults(await this.engine.predictDrawable(data, width, height, p));
432
+ predict = () => this.engine.predictDrawable(data, width, height, p);
463
433
  }
464
- const bytes = await toBytes(image, "image");
465
- return decodeResults(await this.engine.predictEncoded(bytes, p));
434
+ else {
435
+ const bytes = image instanceof Uint8Array
436
+ ? image.slice()
437
+ : image instanceof ArrayBuffer
438
+ ? new Uint8Array(image.slice(0))
439
+ : await toBytes(image, "image");
440
+ predict = () => this.engine.predictEncoded(bytes, p);
441
+ }
442
+ const result = this.queue.then(async () => decodeResults(await predict()));
443
+ this.queue = result.then(() => undefined, () => undefined);
444
+ return result;
466
445
  }
467
446
  /** Release the underlying wasm model/engine. Call when you are done with it. */
468
447
  free() {
@@ -558,10 +537,11 @@ export async function annotate(canvas, image, results, options) {
558
537
  const sin = Math.sin(o.angle);
559
538
  const hw = o.w / 2;
560
539
  const hh = o.h / 2;
540
+ // Same corner order as the native `Obb::xyxyxyxy` and Ultralytics `xywhr2xyxyxyxy`.
561
541
  const corners = [
562
- [-hw, -hh],
563
- [hw, -hh],
564
542
  [hw, hh],
543
+ [hw, -hh],
544
+ [-hw, -hh],
565
545
  [-hw, hh],
566
546
  ].map(([dx, dy]) => [o.x + dx * cos - dy * sin, o.y + dx * sin + dy * cos]);
567
547
  ctx.beginPath();
@@ -575,25 +555,35 @@ export async function annotate(canvas, image, results, options) {
575
555
  // Pose keypoints + skeleton, colored with the engine's pose palette (per-limb
576
556
  // and per-keypoint), matching the native/Python renderer.
577
557
  if (showKpts && results.keypoints.length) {
578
- const { skeleton, keypoint_colors, limb_colors } = poseScheme();
579
- const radius = Math.max(2, Math.round(width / 300));
558
+ const scheme = poseScheme();
559
+ const radius = options?.keypointRadius ?? 5;
560
+ const fixed = options?.keypointColor;
580
561
  ctx.lineWidth = Math.max(1, Math.round(lineWidth / 1.5));
581
562
  for (const kp of results.keypoints) {
582
- skeleton.forEach(([a, b], li) => {
583
- const pa = kp.points[a];
584
- const pb = kp.points[b];
585
- if (!pa || !pb || pa[2] < kptThresh || pb[2] < kptThresh)
586
- return;
587
- ctx.strokeStyle = limb_colors[li] ?? kp.color;
588
- ctx.beginPath();
589
- ctx.moveTo(pa[0], pa[1]);
590
- ctx.lineTo(pb[0], pb[1]);
591
- ctx.stroke();
592
- });
563
+ // Like Ultralytics, only the 17-keypoint COCO-Pose layout gets the pose palette and the
564
+ // human skeleton; other layouts take one palette color per keypoint and no lines.
565
+ const coco = kp.points.length === scheme.keypoint_colors.length;
566
+ const skeleton = options?.skeleton ?? (coco ? scheme.skeleton : []);
567
+ const paletteAt = (i) => scheme.palette[i % scheme.palette.length];
568
+ const limbColor = (i) => fixed ?? (coco && !options?.skeleton ? scheme.limb_colors[i] : paletteAt(i));
569
+ const kptColor = (i) => fixed ?? (coco ? scheme.keypoint_colors[i] : paletteAt(i));
570
+ if (options?.keypointLines ?? true) {
571
+ skeleton.forEach(([a, b], li) => {
572
+ const pa = kp.points[a];
573
+ const pb = kp.points[b];
574
+ if (!pa || !pb || pa[2] < kptThresh || pb[2] < kptThresh)
575
+ return;
576
+ ctx.strokeStyle = limbColor(li);
577
+ ctx.beginPath();
578
+ ctx.moveTo(pa[0], pa[1]);
579
+ ctx.lineTo(pb[0], pb[1]);
580
+ ctx.stroke();
581
+ });
582
+ }
593
583
  kp.points.forEach(([x, y, c], ki) => {
594
584
  if (c < kptThresh)
595
585
  return;
596
- ctx.fillStyle = keypoint_colors[ki] ?? kp.color;
586
+ ctx.fillStyle = kptColor(ki);
597
587
  ctx.beginPath();
598
588
  ctx.arc(x, y, radius, 0, Math.PI * 2);
599
589
  ctx.fill();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultralytics/yolo",
3
- "version": "0.0.53",
3
+ "version": "0.0.55",
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.53",
5
+ "version": "0.0.55",
6
6
  "license": "AGPL-3.0",
7
7
  "repository": {
8
8
  "type": "git",
@@ -100,17 +100,17 @@ export class YoloPipeline {
100
100
  * Postprocess an external engine's raw outputs into the standard `Results`.
101
101
  *
102
102
  * `outputs` are the model's output tensors (one for most tasks; two for
103
- * segmentation: detection head + mask prototypes). `shapes` encodes each
104
- * output's dims flat as `[rank0, dims0..., rank1, dims1...]`. `inference_ms`
103
+ * segmentation: detection head + mask prototypes), with one entry of dims per
104
+ * output in `shapes`. `inference_ms`
105
105
  * is the time the JS engine reported, used only for the `speed` breakdown.
106
106
  * Consumes the frame stashed by the preceding
107
107
  * [`preprocess_rgba`](Self::preprocess_rgba).
108
108
  *
109
109
  * # Errors
110
- * Returns a JS error if called before `preprocess_rgba`, if `shapes` is
111
- * malformed, or on serialization failure.
110
+ * Returns a JS error if called before `preprocess_rgba`, if `shapes` does not
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, iou: number, 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
@@ -140,9 +140,7 @@ export class YoloPipeline {
140
140
  */
141
141
  setInputShape(shape: Int32Array): void;
142
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.
143
+ * Whether this is an NMS-free export, e.g. YOLO26 with `nms=False`.
146
144
  */
147
145
  readonly end2end: boolean;
148
146
  /**
@@ -159,9 +157,7 @@ export class YoloPipeline {
159
157
  */
160
158
  readonly names: any;
161
159
  /**
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.
160
+ * Whether this is an RT-DETR export.
165
161
  */
166
162
  readonly rtdetr: boolean;
167
163
  /**
@@ -207,10 +203,10 @@ export interface InitOutput {
207
203
  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_2005: (a: number, b: number, c: number, d: number) => void;
211
- readonly __wasm_bindgen_func_elem_2005_20: (a: number, b: number, c: number, d: number) => void;
212
- readonly __wasm_bindgen_func_elem_2634: (a: number, b: number, c: number, d: number) => void;
213
- readonly __wasm_bindgen_func_elem_2658: (a: number, b: number, c: number, d: number) => void;
206
+ readonly __wasm_bindgen_func_elem_1192: (a: number, b: number, c: number, d: number) => void;
207
+ readonly __wasm_bindgen_func_elem_1823: (a: number, b: number, c: number, d: number) => void;
208
+ readonly __wasm_bindgen_func_elem_1847: (a: number, b: number, c: number, d: number) => void;
209
+ readonly __wasm_bindgen_func_elem_377: (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
  /**
@@ -208,9 +208,7 @@ export class YoloPipeline {
208
208
  wasm.__wbg_yolopipeline_free(ptr, 0);
209
209
  }
210
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.
211
+ * Whether this is an NMS-free export, e.g. YOLO26 with `nms=False`.
214
212
  * @returns {boolean}
215
213
  */
216
214
  get end2end() {
@@ -292,17 +290,17 @@ export class YoloPipeline {
292
290
  * Postprocess an external engine's raw outputs into the standard `Results`.
293
291
  *
294
292
  * `outputs` are the model's output tensors (one for most tasks; two for
295
- * segmentation: detection head + mask prototypes). `shapes` encodes each
296
- * output's dims flat as `[rank0, dims0..., rank1, dims1...]`. `inference_ms`
293
+ * segmentation: detection head + mask prototypes), with one entry of dims per
294
+ * output in `shapes`. `inference_ms`
297
295
  * is the time the JS engine reported, used only for the `speed` breakdown.
298
296
  * Consumes the frame stashed by the preceding
299
297
  * [`preprocess_rgba`](Self::preprocess_rgba).
300
298
  *
301
299
  * # Errors
302
- * Returns a JS error if called before `preprocess_rgba`, if `shapes` is
303
- * malformed, or on serialization failure.
300
+ * Returns a JS error if called before `preprocess_rgba`, if `shapes` does not
301
+ * have one entry per output, or on serialization failure.
304
302
  * @param {Float32Array[]} outputs
305
- * @param {Uint32Array} shapes
303
+ * @param {Uint32Array[]} shapes
306
304
  * @param {number} inference_ms
307
305
  * @param {number} conf
308
306
  * @param {number} iou
@@ -316,7 +314,7 @@ export class YoloPipeline {
316
314
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
317
315
  const ptr0 = passArrayJsValueToWasm0(outputs, wasm.__wbindgen_export);
318
316
  const len0 = WASM_VECTOR_LEN;
319
- const ptr1 = passArray32ToWasm0(shapes, wasm.__wbindgen_export);
317
+ const ptr1 = passArrayJsValueToWasm0(shapes, wasm.__wbindgen_export);
320
318
  const len1 = WASM_VECTOR_LEN;
321
319
  var ptr2 = isLikeNone(classes) ? 0 : passArray32ToWasm0(classes, wasm.__wbindgen_export);
322
320
  var len2 = WASM_VECTOR_LEN;
@@ -370,9 +368,7 @@ export class YoloPipeline {
370
368
  }
371
369
  }
372
370
  /**
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.
371
+ * Whether this is an RT-DETR export.
376
372
  * @returns {boolean}
377
373
  */
378
374
  get rtdetr() {
@@ -557,25 +553,28 @@ function __wbg_get_imports() {
557
553
  const ret = getObject(arg0).call(getObject(arg1));
558
554
  return addHeapObject(ret);
559
555
  }, arguments); },
560
- __wbg_create_92add3f2dd5e9fec: function() { return handleError(function (arg0, arg1, arg2) {
556
+ __wbg_create_07db378e252080ec: function() { return handleError(function (arg0, arg1, arg2) {
561
557
  const ret = ort.InferenceSession.create(getStringFromWasm0(arg0, arg1), takeObject(arg2));
562
558
  return addHeapObject(ret);
563
559
  }, arguments); },
564
- __wbg_create_c3bda381e473821b: function() { return handleError(function (arg0, arg1) {
560
+ __wbg_create_573b47018e76ad99: function() { return handleError(function (arg0, arg1) {
565
561
  const ret = ort.InferenceSession.create(getObject(arg0), takeObject(arg1));
566
562
  return addHeapObject(ret);
567
563
  }, arguments); },
568
- __wbg_data_7ea15a3ce3038789: function() { return handleError(function (arg0) {
564
+ __wbg_data_e242aa3d2f3b3ce2: function() { return handleError(function (arg0) {
569
565
  const ret = getObject(arg0).data;
570
566
  return addHeapObject(ret);
571
567
  }, arguments); },
572
- __wbg_dims_ad4921ea2a0e2688: function(arg0, arg1) {
568
+ __wbg_dims_b9c966d20c2a4d79: function(arg0, arg1) {
573
569
  const ret = getObject(arg1).dims;
574
- const ptr1 = passArray64ToWasm0(ret, wasm.__wbindgen_export);
570
+ const ptr1 = passArrayF64ToWasm0(ret, wasm.__wbindgen_export);
575
571
  const len1 = WASM_VECTOR_LEN;
576
572
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
577
573
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
578
574
  },
575
+ __wbg_dispose_17a92fe091ac456b: function() { return handleError(function (arg0) {
576
+ getObject(arg0).dispose();
577
+ }, arguments); },
579
578
  __wbg_done_b41a1d26cdb37fb6: function(arg0) {
580
579
  const ret = getObject(arg0).done;
581
580
  return ret;
@@ -599,7 +598,7 @@ function __wbg_get_imports() {
599
598
  const ret = Array.from(getObject(arg0));
600
599
  return addHeapObject(ret);
601
600
  },
602
- __wbg_getData_636da3f54c76e83d: function() { return handleError(function (arg0) {
601
+ __wbg_getData_ae0be7023598e2c2: function() { return handleError(function (arg0) {
603
602
  const ret = getObject(arg0).getData();
604
603
  return addHeapObject(ret);
605
604
  }, arguments); },
@@ -623,18 +622,18 @@ function __wbg_get_imports() {
623
622
  const ret = getObject(arg0)[getObject(arg1)];
624
623
  return addHeapObject(ret);
625
624
  },
626
- __wbg_initRuntime_b299fae72b0dc4e0: function() { return handleError(function (arg0, arg1) {
625
+ __wbg_initRuntime_cfc81535b182a89a: function() { return handleError(function (arg0, arg1) {
627
626
  const ret = initRuntime(arg0, takeObject(arg1));
628
627
  return addHeapObject(ret);
629
628
  }, arguments); },
630
- __wbg_inputMetadata_d393d214fc106b6b: function(arg0, arg1) {
629
+ __wbg_inputMetadata_b0480cebe7a00667: function(arg0, arg1) {
631
630
  const ret = getObject(arg1).inputMetadata;
632
631
  const ptr1 = passArrayJsValueToWasm0(ret, wasm.__wbindgen_export);
633
632
  const len1 = WASM_VECTOR_LEN;
634
633
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
635
634
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
636
635
  },
637
- __wbg_inputNames_724b40f0a2d8fba4: function(arg0, arg1) {
636
+ __wbg_inputNames_2897599e914f9792: function(arg0, arg1) {
638
637
  const ret = getObject(arg1).inputNames;
639
638
  const ptr1 = passArrayJsValueToWasm0(ret, wasm.__wbindgen_export);
640
639
  const len1 = WASM_VECTOR_LEN;
@@ -661,20 +660,20 @@ function __wbg_get_imports() {
661
660
  const ret = result;
662
661
  return ret;
663
662
  },
664
- __wbg_instanceof_Uint8Array_828cef2aaacafc31: function(arg0) {
663
+ __wbg_instanceof_Performance_cbec0dbedaa91be1: function(arg0) {
665
664
  let result;
666
665
  try {
667
- result = getObject(arg0) instanceof Uint8Array;
666
+ result = getObject(arg0) instanceof Performance;
668
667
  } catch (_) {
669
668
  result = false;
670
669
  }
671
670
  const ret = result;
672
671
  return ret;
673
672
  },
674
- __wbg_instanceof_Window_82d71df4eddf88bc: function(arg0) {
673
+ __wbg_instanceof_Uint8Array_828cef2aaacafc31: function(arg0) {
675
674
  let result;
676
675
  try {
677
- result = getObject(arg0) instanceof Window;
676
+ result = getObject(arg0) instanceof Uint8Array;
678
677
  } catch (_) {
679
678
  result = false;
680
679
  }
@@ -693,6 +692,10 @@ function __wbg_get_imports() {
693
692
  const ret = Symbol.iterator;
694
693
  return addHeapObject(ret);
695
694
  },
695
+ __wbg_length_511b1f84719d3462: function(arg0) {
696
+ const ret = getObject(arg0).length;
697
+ return ret;
698
+ },
696
699
  __wbg_length_58572db4c38f3c3e: function(arg0) {
697
700
  const ret = getObject(arg0).length;
698
701
  return ret;
@@ -705,10 +708,14 @@ function __wbg_get_imports() {
705
708
  const ret = getObject(arg0).length;
706
709
  return ret;
707
710
  },
708
- __wbg_location_348911e2e503af1d: function(arg0) {
711
+ __wbg_location_02e5bf0e6b80a0f5: function(arg0) {
709
712
  const ret = getObject(arg0).location;
710
713
  return (__wbindgen_enum_DataLocation.indexOf(ret) + 1 || 7) - 1;
711
714
  },
715
+ __wbg_message_5f8387f0c32b90a7: function(arg0) {
716
+ const ret = getObject(arg0).message;
717
+ return addHeapObject(ret);
718
+ },
712
719
  __wbg_new_1dbf7428bba60a42: function(arg0) {
713
720
  const ret = new Uint8Array(getObject(arg0));
714
721
  return addHeapObject(ret);
@@ -729,10 +736,14 @@ function __wbg_get_imports() {
729
736
  const ret = new Array();
730
737
  return addHeapObject(ret);
731
738
  },
732
- __wbg_new_from_buffer_raw_1a36905fc3da3c96: function() { return handleError(function (arg0, arg1, arg2) {
739
+ __wbg_new_from_buffer_raw_eb33cdffdf32a27b: function() { return handleError(function (arg0, arg1, arg2) {
733
740
  const ret = new ort.Tensor(__wbindgen_enum_DataType[arg0], takeObject(arg1), takeObject(arg2));
734
741
  return addHeapObject(ret);
735
742
  }, arguments); },
743
+ __wbg_new_from_slice_9a868026ffa4208a: function(arg0, arg1) {
744
+ const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
745
+ return addHeapObject(ret);
746
+ },
736
747
  __wbg_new_from_slice_ca6ad97db1f4779a: function(arg0, arg1) {
737
748
  const ret = new Float32Array(getArrayF32FromWasm0(arg0, arg1));
738
749
  return addHeapObject(ret);
@@ -744,7 +755,7 @@ function __wbg_get_imports() {
744
755
  const a = state0.a;
745
756
  state0.a = 0;
746
757
  try {
747
- return __wasm_bindgen_func_elem_2658(a, state0.b, arg0, arg1);
758
+ return __wasm_bindgen_func_elem_1847(a, state0.b, arg0, arg1);
748
759
  } finally {
749
760
  state0.a = a;
750
761
  }
@@ -755,48 +766,44 @@ function __wbg_get_imports() {
755
766
  state0.a = 0;
756
767
  }
757
768
  },
758
- __wbg_new_with_byte_offset_and_length_2f5d7fc2a828b74d: function(arg0, arg1, arg2) {
759
- const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
760
- return addHeapObject(ret);
761
- },
762
- __wbg_new_with_length_10ec131ed0376a89: function(arg0) {
763
- const ret = new Int8Array(arg0 >>> 0);
769
+ __wbg_new_with_byte_offset_and_length_1dc9f6fbbe046da6: function(arg0, arg1, arg2) {
770
+ const ret = new Uint16Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
764
771
  return addHeapObject(ret);
765
772
  },
766
- __wbg_new_with_length_1135aa9e3c0fb17c: function(arg0) {
767
- const ret = new BigUint64Array(arg0 >>> 0);
773
+ __wbg_new_with_byte_offset_and_length_2f5d7fc2a828b74d: function(arg0, arg1, arg2) {
774
+ const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
768
775
  return addHeapObject(ret);
769
776
  },
770
- __wbg_new_with_length_178f83910c35a379: function(arg0) {
771
- const ret = new BigInt64Array(arg0 >>> 0);
777
+ __wbg_new_with_byte_offset_and_length_40c170286adc9005: function(arg0, arg1, arg2) {
778
+ const ret = new Float32Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
772
779
  return addHeapObject(ret);
773
780
  },
774
- __wbg_new_with_length_31d0d732d07f3195: function(arg0) {
775
- const ret = new Uint32Array(arg0 >>> 0);
781
+ __wbg_new_with_byte_offset_and_length_6e8c68600a3ecb84: function(arg0, arg1, arg2) {
782
+ const ret = new BigUint64Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
776
783
  return addHeapObject(ret);
777
784
  },
778
- __wbg_new_with_length_3827645dc5adb679: function(arg0) {
779
- const ret = new Float64Array(arg0 >>> 0);
785
+ __wbg_new_with_byte_offset_and_length_820ea3ecbd1a4828: function(arg0, arg1, arg2) {
786
+ const ret = new Int16Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
780
787
  return addHeapObject(ret);
781
788
  },
782
- __wbg_new_with_length_3da0ad195f6f63ba: function(arg0) {
783
- const ret = new Uint8Array(arg0 >>> 0);
789
+ __wbg_new_with_byte_offset_and_length_915c5de4270ab7e5: function(arg0, arg1, arg2) {
790
+ const ret = new Int8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
784
791
  return addHeapObject(ret);
785
792
  },
786
- __wbg_new_with_length_42910c27ec097fc3: function(arg0) {
787
- const ret = new Int32Array(arg0 >>> 0);
793
+ __wbg_new_with_byte_offset_and_length_b93e61c4e9440336: function(arg0, arg1, arg2) {
794
+ const ret = new Int32Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
788
795
  return addHeapObject(ret);
789
796
  },
790
- __wbg_new_with_length_6b2193ba95fe514b: function(arg0) {
791
- const ret = new Uint16Array(arg0 >>> 0);
797
+ __wbg_new_with_byte_offset_and_length_bf3e693fe2fffb6f: function(arg0, arg1, arg2) {
798
+ const ret = new Uint32Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
792
799
  return addHeapObject(ret);
793
800
  },
794
- __wbg_new_with_length_a29f4581839a9ad6: function(arg0) {
795
- const ret = new Int16Array(arg0 >>> 0);
801
+ __wbg_new_with_byte_offset_and_length_c14d867a5878f875: function(arg0, arg1, arg2) {
802
+ const ret = new BigInt64Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
796
803
  return addHeapObject(ret);
797
804
  },
798
- __wbg_new_with_length_cc0362bfe8499e5a: function(arg0) {
799
- const ret = new Float32Array(arg0 >>> 0);
805
+ __wbg_new_with_byte_offset_and_length_edf873b0b3173456: function(arg0, arg1, arg2) {
806
+ const ret = new Float64Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
800
807
  return addHeapObject(ret);
801
808
  },
802
809
  __wbg_next_33784799010f1bbe: function(arg0) {
@@ -811,14 +818,14 @@ function __wbg_get_imports() {
811
818
  const ret = getObject(arg0).now();
812
819
  return ret;
813
820
  },
814
- __wbg_outputMetadata_7300f513b14cec51: function(arg0, arg1) {
821
+ __wbg_outputMetadata_d74fba311b0cce30: function(arg0, arg1) {
815
822
  const ret = getObject(arg1).outputMetadata;
816
823
  const ptr1 = passArrayJsValueToWasm0(ret, wasm.__wbindgen_export);
817
824
  const len1 = WASM_VECTOR_LEN;
818
825
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
819
826
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
820
827
  },
821
- __wbg_outputNames_9d56e41945ee91d5: function(arg0, arg1) {
828
+ __wbg_outputNames_26deb7d052bac410: function(arg0, arg1) {
822
829
  const ret = getObject(arg1).outputNames;
823
830
  const ptr1 = passArrayJsValueToWasm0(ret, wasm.__wbindgen_export);
824
831
  const len1 = WASM_VECTOR_LEN;
@@ -829,9 +836,8 @@ function __wbg_get_imports() {
829
836
  const ret = Reflect.ownKeys(getObject(arg0));
830
837
  return addHeapObject(ret);
831
838
  }, arguments); },
832
- __wbg_performance_d0d7b03fc649b694: function(arg0) {
833
- const ret = getObject(arg0).performance;
834
- return isLikeNone(ret) ? 0 : addHeapObject(ret);
839
+ __wbg_prototypesetcall_06eb15da165dee8f: function(arg0, arg1, arg2) {
840
+ Uint32Array.prototype.set.call(getArrayU32FromWasm0(arg0, arg1), getObject(arg2));
835
841
  },
836
842
  __wbg_prototypesetcall_8b03c01e2c0f8066: function(arg0, arg1, arg2) {
837
843
  Float32Array.prototype.set.call(getArrayF32FromWasm0(arg0, arg1), getObject(arg2));
@@ -850,18 +856,25 @@ function __wbg_get_imports() {
850
856
  __wbg_queueMicrotask_a72f977e97f23c5f: function(arg0) {
851
857
  queueMicrotask(getObject(arg0));
852
858
  },
859
+ __wbg_release_0dd02e33b7cd324c: function() { return handleError(function (arg0) {
860
+ const ret = getObject(arg0).release();
861
+ return addHeapObject(ret);
862
+ }, arguments); },
853
863
  __wbg_resolve_0076e10020304ede: function(arg0) {
854
864
  const ret = Promise.resolve(getObject(arg0));
855
865
  return addHeapObject(ret);
856
866
  },
857
- __wbg_run_9e09e7300abe14f9: function() { return handleError(function (arg0, arg1) {
858
- const ret = getObject(arg0).run(takeObject(arg1));
867
+ __wbg_run_2893666784c8891d: function() { return handleError(function (arg0, arg1, arg2, arg3) {
868
+ const ret = getObject(arg0).run(takeObject(arg1), takeObject(arg2), takeObject(arg3));
859
869
  return addHeapObject(ret);
860
870
  }, arguments); },
861
871
  __wbg_set_145a351398b48c65: function() { return handleError(function (arg0, arg1, arg2) {
862
872
  const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
863
873
  return ret;
864
874
  }, arguments); },
875
+ __wbg_set_34d08fd992d43d61: function(arg0, arg1, arg2) {
876
+ getObject(arg0).set(getObject(arg1), arg2 >>> 0);
877
+ },
865
878
  __wbg_set_575d3ddb70fe831d: function(arg0, arg1, arg2) {
866
879
  getObject(arg0).set(getArrayU8FromWasm0(arg1, arg2));
867
880
  },
@@ -917,11 +930,11 @@ function __wbg_get_imports() {
917
930
  const ret = getObject(arg0).toString();
918
931
  return addHeapObject(ret);
919
932
  },
920
- __wbg_trackSessionInit_802b774d44772d22: function() { return handleError(function (arg0, arg1) {
933
+ __wbg_trackSessionInit_b37a6598a5541f10: function() { return handleError(function (arg0, arg1) {
921
934
  const ret = trackSessionInit(getStringFromWasm0(arg0, arg1));
922
935
  return addHeapObject(ret);
923
936
  }, arguments); },
924
- __wbg_type_80ea00300eb18928: function(arg0) {
937
+ __wbg_type_e1fd5cc29b264a06: function(arg0) {
925
938
  const ret = getObject(arg0).type;
926
939
  return (__wbindgen_enum_DataType.indexOf(ret) + 1 || 16) - 1;
927
940
  },
@@ -934,18 +947,18 @@ function __wbg_get_imports() {
934
947
  return addHeapObject(ret);
935
948
  },
936
949
  __wbindgen_generic_0000000000000001: function(arg0, arg1) {
937
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 690, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
938
- const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_2005);
950
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 364, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
951
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_1192);
939
952
  return addHeapObject(ret);
940
953
  },
941
954
  __wbindgen_generic_0000000000000002: function(arg0, arg1) {
942
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 933, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
943
- const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_2634);
955
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 648, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
956
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_1823);
944
957
  return addHeapObject(ret);
945
958
  },
946
959
  __wbindgen_generic_0000000000000003: function(arg0, arg1) {
947
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("boolean")], shim_idx: 690, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
948
- const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_2005_20);
960
+ // 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`.
961
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_377);
949
962
  return addHeapObject(ret);
950
963
  },
951
964
  __wbindgen_generic_0000000000000004: function(arg0) {
@@ -1032,14 +1045,14 @@ function __wbg_get_imports() {
1032
1045
  };
1033
1046
  }
1034
1047
 
1035
- function __wasm_bindgen_func_elem_2658(arg0, arg1, arg2, arg3) {
1036
- wasm.__wasm_bindgen_func_elem_2658(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
1048
+ function __wasm_bindgen_func_elem_1847(arg0, arg1, arg2, arg3) {
1049
+ wasm.__wasm_bindgen_func_elem_1847(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
1037
1050
  }
1038
1051
 
1039
- function __wasm_bindgen_func_elem_2005(arg0, arg1, arg2) {
1052
+ function __wasm_bindgen_func_elem_1192(arg0, arg1, arg2) {
1040
1053
  try {
1041
1054
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1042
- wasm.__wasm_bindgen_func_elem_2005(retptr, arg0, arg1, addHeapObject(arg2));
1055
+ wasm.__wasm_bindgen_func_elem_1192(retptr, arg0, arg1, addHeapObject(arg2));
1043
1056
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1044
1057
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1045
1058
  if (r1) {
@@ -1050,10 +1063,10 @@ function __wasm_bindgen_func_elem_2005(arg0, arg1, arg2) {
1050
1063
  }
1051
1064
  }
1052
1065
 
1053
- function __wasm_bindgen_func_elem_2634(arg0, arg1, arg2) {
1066
+ function __wasm_bindgen_func_elem_1823(arg0, arg1, arg2) {
1054
1067
  try {
1055
1068
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1056
- wasm.__wasm_bindgen_func_elem_2634(retptr, arg0, arg1, addHeapObject(arg2));
1069
+ wasm.__wasm_bindgen_func_elem_1823(retptr, arg0, arg1, addHeapObject(arg2));
1057
1070
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1058
1071
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1059
1072
  if (r1) {
@@ -1064,10 +1077,10 @@ function __wasm_bindgen_func_elem_2634(arg0, arg1, arg2) {
1064
1077
  }
1065
1078
  }
1066
1079
 
1067
- function __wasm_bindgen_func_elem_2005_20(arg0, arg1, arg2) {
1080
+ function __wasm_bindgen_func_elem_377(arg0, arg1, arg2) {
1068
1081
  try {
1069
1082
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1070
- wasm.__wasm_bindgen_func_elem_2005_20(retptr, arg0, arg1, addHeapObject(arg2));
1083
+ wasm.__wasm_bindgen_func_elem_377(retptr, arg0, arg1, addHeapObject(arg2));
1071
1084
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1072
1085
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1073
1086
  if (r1) {
@@ -1370,16 +1383,16 @@ function passArray32ToWasm0(arg, malloc) {
1370
1383
  return ptr;
1371
1384
  }
1372
1385
 
1373
- function passArray64ToWasm0(arg, malloc) {
1374
- const ptr = malloc(arg.length * 8, 8) >>> 0;
1375
- getBigUint64ArrayMemory0().set(arg, ptr / 8);
1386
+ function passArray8ToWasm0(arg, malloc) {
1387
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
1388
+ getUint8ArrayMemory0().set(arg, ptr / 1);
1376
1389
  WASM_VECTOR_LEN = arg.length;
1377
1390
  return ptr;
1378
1391
  }
1379
1392
 
1380
- function passArray8ToWasm0(arg, malloc) {
1381
- const ptr = malloc(arg.length * 1, 1) >>> 0;
1382
- getUint8ArrayMemory0().set(arg, ptr / 1);
1393
+ function passArrayF64ToWasm0(arg, malloc) {
1394
+ const ptr = malloc(arg.length * 8, 8) >>> 0;
1395
+ getFloat64ArrayMemory0().set(arg, ptr / 8);
1383
1396
  WASM_VECTOR_LEN = arg.length;
1384
1397
  return ptr;
1385
1398
  }
@@ -20,10 +20,10 @@ export const yolopipeline_preprocess_rgba: (a: number, b: number, c: number, d:
20
20
  export const yolopipeline_rtdetr: (a: number) => number;
21
21
  export const yolopipeline_setInputShape: (a: number, b: number, c: number) => void;
22
22
  export const yolopipeline_task: (a: number, b: number) => void;
23
- export const __wasm_bindgen_func_elem_2005: (a: number, b: number, c: number, d: number) => void;
24
- export const __wasm_bindgen_func_elem_2005_20: (a: number, b: number, c: number, d: number) => void;
25
- export const __wasm_bindgen_func_elem_2634: (a: number, b: number, c: number, d: number) => void;
26
- export const __wasm_bindgen_func_elem_2658: (a: number, b: number, c: number, d: number) => void;
23
+ export const __wasm_bindgen_func_elem_1192: (a: number, b: number, c: number, d: number) => void;
24
+ export const __wasm_bindgen_func_elem_1823: (a: number, b: number, c: number, d: number) => void;
25
+ export const __wasm_bindgen_func_elem_1847: (a: number, b: number, c: number, d: number) => void;
26
+ export const __wasm_bindgen_func_elem_377: (a: number, b: number, c: number, d: number) => void;
27
27
  export const __wbindgen_export: (a: number, b: number) => number;
28
28
  export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
29
29
  export const __wbindgen_export3: (a: number) => void;