@ultralytics/yolo 0.0.40 → 0.0.42

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
@@ -32,11 +32,7 @@
32
32
 
33
33
  </div>
34
34
 
35
- Run [Ultralytics](https://www.ultralytics.com) YOLO models directly in the browser,
36
- with no server and no Python. It runs on **WebGPU** (with an automatic CPU/wasm
37
- fallback) and covers detection, segmentation, pose, classification, OBB,
38
- semantic segmentation, and depth estimation, behind a small TypeScript API with a built-in
39
- `annotate()` that draws results straight to a canvas.
35
+ Run [Ultralytics](https://www.ultralytics.com) YOLO models directly in the browser, with no server and no Python. It runs on **WebGPU** (with an automatic CPU/wasm fallback) and covers [object detection](https://docs.ultralytics.com/tasks/detect), [instance segmentation](https://docs.ultralytics.com/tasks/segment), [pose estimation](https://docs.ultralytics.com/tasks/pose), [image classification](https://docs.ultralytics.com/tasks/classify), [oriented bounding boxes](https://docs.ultralytics.com/tasks/obb), [semantic segmentation](https://docs.ultralytics.com/tasks/semantic), and [depth estimation](https://docs.ultralytics.com/tasks/depth), behind a small TypeScript API with a built-in `annotate()` that draws results straight to a canvas.
40
36
 
41
37
  ```ts
42
38
  import { YOLO, annotate } from "@ultralytics/yolo";
@@ -185,7 +181,7 @@ await annotate(canvas, img, results, { depthAlpha: 0.6 });
185
181
  `YOLO.load("/models/yolo26n.onnx", { device: "webgpu" | "cpu" })` (default `"auto"`). If
186
182
  WebGPU cannot engage, the load falls back to CPU; `model.device` reports what
187
183
  actually ran.
188
- - **Model format**: export your model to ONNX with Ultralytics so the metadata
184
+ - **Model format**: export your model to ONNX with Ultralytics `>=8.4.142` so the metadata
189
185
  (task, class names, `imgsz`) is embedded:
190
186
 
191
187
  ```python
@@ -195,6 +191,11 @@ await annotate(canvas, img, results, { depthAlpha: 0.6 });
195
191
  YOLO("yolo26n.pt").export(format="onnx", quantize=16) # FP16 (~50% smaller)
196
192
  ```
197
193
 
194
+ For detect, segment, pose, and OBB, `nms=None` (the default) exports raw outputs
195
+ for NMS in Rust; `nms=False` selects the NMS-free head when available (e.g. YOLO26);
196
+ `nms=True` embeds NMS in the ONNX graph. Use `nms=None` for semantic, depth, and classify.
197
+ Existing compatible ONNX files do not need re-exporting.
198
+
198
199
  > Ultralytics ≥8.4 uses the `quantize` argument instead of the deprecated
199
200
  > `half=True` / `int8=True` flags. For ONNX the supported values are
200
201
  > `32`/`fp32` (default), `16`/`fp16`, and `8`/`int8`; the old flags still work
@@ -223,8 +224,8 @@ Only the inference engine changes; the preprocessing, postprocessing, drawing,
223
224
  and `Results` shape are the same shared Rust code, so output matches the `ort`
224
225
  path.
225
226
 
226
- The backend is picked from the file extension: a `.tflite` runs on LiteRT.js, a
227
- `.onnx` on ONNX Runtime Web. The LiteRT.js wasm loads from a CDN by default, so
227
+ The backend is picked from the file extension, falling back to sniffing the `TFL3`
228
+ magic bytes: a `.tflite` runs on LiteRT.js, a `.onnx` on ONNX Runtime Web. The LiteRT.js wasm loads from a CDN by default, so
228
229
  the only setup is making `@litertjs/core` resolve (along with its `@litertjs/wasm-utils`
229
230
  dependency, which npm installs automatically and the import map below lists explicitly).
230
231
 
@@ -272,21 +273,21 @@ Notes:
272
273
  - **Model**: export with Ultralytics to `.tflite` (float32 for WebGPU). It loads
273
274
  from the single file. The metadata (task, class names, `imgsz`, stride) is read
274
275
  straight from the `.tflite`, the same as the `.onnx` path. No sidecar.
275
- - **Requires Ultralytics `>= 8.4.83`**: the single-file LiteRT export (with
276
+ - **Existing model compatibility**: the single-file LiteRT export (with
276
277
  embedded metadata) ships in
277
278
  [v8.4.83](https://github.com/ultralytics/ultralytics/releases/tag/v8.4.83) and
278
279
  later. Earlier versions emit the legacy TFLite format and won't load here.
279
- - **Export end2end-free models** (`end2end=False`): Ultralytics YOLO26 defaults to an
280
- end-to-end, NMS-free head whose `int64` / `gather_nd` ops the LiteRT
281
- **WebGPU** delegate cannot run, so those exports silently fall back to CPU/wasm.
282
- Export them with `end2end=False` so the standard head is used and NMS runs in
283
- this package's Rust, keeping inference on WebGPU:
280
+ - **Keep the one-to-many head for WebGPU** (`nms=None`): the NMS-free YOLO26 head, exported
281
+ with `nms=False`, has `int64` / `gather_nd` ops the LiteRT **WebGPU** delegate cannot
282
+ run, so those exports fall back to CPU/wasm. Use Ultralytics `>=8.4.142` for this recipe; it exports
283
+ the one-to-many head by default, so NMS runs in this package's Rust and inference stays
284
+ on WebGPU:
284
285
 
285
286
  ```bash
286
- yolo export model=yolo26n.pt format=litert end2end=False
287
+ yolo export model=yolo26n.pt format=litert nms=None
287
288
  ```
288
289
 
289
- If you load an end2end `.tflite` anyway, the backend auto-switches it to wasm
290
+ If you load an NMS-free `.tflite`, the backend auto-switches it to wasm
290
291
  (slower) and logs a warning rather than returning empty results.
291
292
 
292
293
  - **Tasks**: detect, segment, pose, obb, classify, semantic, and depth are all supported.
package/README.zh-CN.md CHANGED
@@ -32,9 +32,7 @@
32
32
 
33
33
  </div>
34
34
 
35
- 直接在浏览器中运行 [Ultralytics](https://www.ultralytics.com) YOLO 模型,无需服务器,也无需
36
- Python。本库基于 **WebGPU**(并自动回退到 CPU/wasm),支持检测、分割、姿态、分类、OBB、语义分割和
37
- 深度估计,接口是一个小巧的 TypeScript API,内置的 `annotate()` 可直接把结果绘制到 canvas 上。
35
+ 直接在浏览器中运行 [Ultralytics](https://www.ultralytics.com) YOLO 模型,无需服务器,也无需 Python。本库基于 **WebGPU**(并自动回退到 CPU/wasm),支持[目标检测](https://docs.ultralytics.com/tasks/detect)、[实例分割](https://docs.ultralytics.com/tasks/segment)、[姿态估计](https://docs.ultralytics.com/tasks/pose)、[图像分类](https://docs.ultralytics.com/tasks/classify)、[旋转边界框](https://docs.ultralytics.com/tasks/obb)、[语义分割](https://docs.ultralytics.com/tasks/semantic)和[深度估计](https://docs.ultralytics.com/tasks/depth),接口是一个小巧的 TypeScript API,内置的 `annotate()` 可直接把结果绘制到 canvas 上。
38
36
 
39
37
  ```ts
40
38
  import { YOLO, annotate } from "@ultralytics/yolo";
@@ -174,15 +172,19 @@ await annotate(canvas, img, results, { depthAlpha: 0.6 });
174
172
  `YOLO.load` 会自动回退到通用的 **CPU/wasm** 构建,随处可用。可通过
175
173
  `YOLO.load("/models/yolo26n.onnx", { device: "webgpu" | "cpu" })` 指定设备(默认 `"auto"`)。若 WebGPU
176
174
  无法启用,加载会回退到 CPU;`model.device` 会报告实际使用的设备。
177
- - **模型格式**:请使用 Ultralytics 导出为 ONNX,以便元数据(任务、类别名称、`imgsz`)被嵌入模型:
175
+ - **模型格式**:请使用 Ultralytics `>=8.4.142` 导出为 ONNX,以便元数据(任务、类别名称、`imgsz`)被嵌入模型:
178
176
 
179
177
  ```python
180
178
  from ultralytics import YOLO
181
179
 
182
- YOLO("yolo26n.pt").export(format="onnx") # FP32(默认)
183
- YOLO("yolo26n.pt").export(format="onnx", quantize=16) # FP16(体积约小 50%)
180
+ YOLO("yolo26n.pt").export(format="onnx") # FP32 (默认)
181
+ YOLO("yolo26n.pt").export(format="onnx", quantize=16) # FP16 (体积约小 50%)
184
182
  ```
185
183
 
184
+ 对于 detect、segment、pose 和 OBB,`nms=None`(默认值)导出原始输出,由 Rust 执行 NMS;
185
+ `nms=False` 在模型支持时选择无 NMS 检测头(例如 YOLO26);`nms=True` 将 NMS 嵌入 ONNX 图中。
186
+ semantic、depth 和 classify 使用 `nms=None`。现有的兼容 ONNX 文件无需重新导出。
187
+
186
188
  > Ultralytics ≥8.4 使用 `quantize` 参数,取代已弃用的 `half=True` / `int8=True` 标志。
187
189
  > 对于 ONNX,支持的取值为 `32`/`fp32`(默认)、`16`/`fp16` 和 `8`/`int8`;旧标志
188
190
  > 仍可使用,但会触发弃用警告。
@@ -205,7 +207,7 @@ await annotate(canvas, img, results, { depthAlpha: 0.6 });
205
207
  **通常比 ONNX Runtime Web 快约 2 倍**。只有推理引擎发生变化,前处理、后处理、绘制和 `Results`
206
208
  结构仍是同一份共享 Rust 代码,因此输出与 `ort` 路径一致。
207
209
 
208
- 后端根据文件扩展名选择:`.tflite` 使用 LiteRT.js,`.onnx` 使用 ONNX Runtime Web。LiteRT.js 的
210
+ 后端根据文件扩展名选择,无扩展名时回退到嗅探 `TFL3` 魔数:`.tflite` 使用 LiteRT.js,`.onnx` 使用 ONNX Runtime Web。LiteRT.js 的
209
211
  wasm 默认从 CDN 加载,因此唯一需要做的就是让 `@litertjs/core` 能被解析(连同它的
210
212
  `@litertjs/wasm-utils` 依赖,npm 会自动安装,下面的 import map 中也显式列出)。
211
213
 
@@ -252,19 +254,19 @@ wasm 默认从 jsDelivr CDN 加载;向 `YOLO.load` 传入 `litertWasmUrl: "/li
252
254
  - **模型**:使用 Ultralytics 导出为 `.tflite`(WebGPU 需要 float32)。模型从单个文件加载,
253
255
  元数据(任务、类别名称、`imgsz`、stride)直接从 `.tflite` 中读取,与 `.onnx` 路径相同,
254
256
  无需额外的附属文件。
255
- - **需要 Ultralytics `>= 8.4.83`**:带内嵌元数据的单文件 LiteRT 导出自
257
+ - **现有模型兼容性**:带内嵌元数据的单文件 LiteRT 导出自
256
258
  [v8.4.83](https://github.com/ultralytics/ultralytics/releases/tag/v8.4.83) 起提供。更早的版本
257
259
  会导出旧版 TFLite 格式,无法在这里加载。
258
- - **导出非 end2end 模型**(`end2end=False`):Ultralytics YOLO26 默认使用端到端、无 NMS 的检测头,
259
- 其中的 `int64` / `gather_nd` 算子无法在 LiteRT 的 **WebGPU** delegate 上运行,因此这类导出会
260
- 静默回退到 CPU/wasm。请使用 `end2end=False` 导出,以便使用标准检测头,并由本包的 Rust 代码执行
261
- NMS,从而让推理保持在 WebGPU 上:
260
+ - **为 WebGPU 保留一对多检测头**(`nms=None`):以 `nms=False` 导出的 YOLO26 无 NMS 检测头包含
261
+ `int64` / `gather_nd` 算子,无法在 LiteRT 的 **WebGPU** delegate 上运行,因此这类导出会
262
+ 回退到 CPU/wasm。以下命令需要 Ultralytics `>=8.4.142`,默认导出一对多检测头,NMS 由本包的 Rust 代码执行,
263
+ 推理得以保持在 WebGPU 上:
262
264
 
263
265
  ```bash
264
- yolo export model=yolo26n.pt format=litert end2end=False
266
+ yolo export model=yolo26n.pt format=litert nms=None
265
267
  ```
266
268
 
267
- 如果仍然加载了 end2end 的 `.tflite`,后端会自动切换到 wasm(较慢)并打印警告,而不是返回空结果。
269
+ 如果加载了无 NMS 的 `.tflite`,后端会自动切换到 wasm(较慢)并打印警告,而不是返回空结果。
268
270
 
269
271
  - **支持的任务**:detect、segment、pose、obb、classify、semantic 和 depth 均已支持。
270
272
  - **跨源隔离**:LiteRT 的多线程 wasm 需要 `SharedArrayBuffer`,因此请以
package/dist/index.d.ts CHANGED
@@ -82,7 +82,9 @@ 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`. Use an absolute URL ending in `/`.
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"`
87
+ * device and the WebGPU fallback below load. Use an absolute URL ending in `/`.
86
88
  */
87
89
  ortBaseUrl?: string | URL;
88
90
  /**
@@ -98,6 +100,9 @@ export interface LoadOptions {
98
100
  * `.tflite` (run through LiteRT.js). Defaults to the jsDelivr CDN. Self-host by
99
101
  * copying `node_modules/@litertjs/core/wasm/` and pointing here (absolute URL
100
102
  * ending in `/`). Requires the optional `@litertjs/core` peer dependency.
103
+ *
104
+ * Required on a cross-origin-isolated page: `COEP: require-corp` blocks the worker
105
+ * LiteRT starts from the default CDN, so the wasm has to come from your own origin.
101
106
  */
102
107
  litertWasmUrl?: string | URL;
103
108
  }
@@ -169,7 +174,7 @@ export declare class YOLO {
169
174
  private static loadLiteRt;
170
175
  /** The model's task (`detect`, `segment`, `pose`, `classify`, `obb`, `semantic`, `depth`). */
171
176
  get task(): string;
172
- /** The active device that ran inference (`"webgpu"`, `"wasm"`, or `"cpu"`). */
177
+ /** The active device that ran inference (`"webgpu"` or `"cpu"`). */
173
178
  get device(): string;
174
179
  /** Class id -> name map (like Ultralytics `model.names`). */
175
180
  get names(): Record<number, string>;
@@ -182,7 +187,7 @@ export declare class YOLO {
182
187
  * are decoded (in wasm for `ort`, via a canvas for `litert`).
183
188
  *
184
189
  * @param image The image to run on.
185
- * @param options Confidence/IoU thresholds.
190
+ * @param options Confidence/IoU thresholds, class filter, and depth colorizing.
186
191
  */
187
192
  predict(image: ImageInput, options?: PredictOptions): Promise<Results>;
188
193
  /** Release the underlying wasm model/engine. Call when you are done with it. */
package/dist/index.js CHANGED
@@ -166,6 +166,23 @@ async function importLiteRt() {
166
166
  // (reload to switch) rather than silently reusing the original assets.
167
167
  let litertInit = null;
168
168
  let litertInitUrl = null;
169
+ /** Reject a cross-origin wasm URL on an isolated page before LiteRT fails on it.
170
+ *
171
+ * Threads need `crossOriginIsolated`, which needs `COEP: require-corp`, and that blocks
172
+ * the worker LiteRT starts from another origin. The default URL is a CDN, so the two
173
+ * settings are mutually exclusive and the failure otherwise arrives as a bare
174
+ * `SecurityError: Failed to construct 'Worker'`.
175
+ */
176
+ function checkWasmUrlReachable(wasmUrl) {
177
+ if (typeof crossOriginIsolated === "undefined" || !crossOriginIsolated)
178
+ return;
179
+ if (typeof location === "undefined")
180
+ return;
181
+ const origin = new URL(wasmUrl, location.href).origin;
182
+ if (origin === location.origin)
183
+ return;
184
+ throw new Error(`LiteRT.js wasm must be served from this origin on a cross-origin-isolated page: "${wasmUrl}" is on ${origin}, and COEP blocks the worker it starts. Copy node_modules/@litertjs/core/wasm/ next to your app and pass it as litertWasmUrl, or drop COOP/COEP to give up WASM threads.`);
185
+ }
169
186
  function ensureLiteRtRuntime(litert, wasmUrl) {
170
187
  if (litertInit) {
171
188
  if (litertInitUrl !== wasmUrl) {
@@ -173,6 +190,7 @@ function ensureLiteRtRuntime(litert, wasmUrl) {
173
190
  }
174
191
  return litertInit;
175
192
  }
193
+ checkWasmUrlReachable(wasmUrl);
176
194
  litertInitUrl = wasmUrl;
177
195
  // Enable WASM multithreading when the page is cross-origin isolated (COOP/COEP
178
196
  // set, so SharedArrayBuffer is available); otherwise LiteRT.js runs single-
@@ -262,11 +280,11 @@ class OrtEngine {
262
280
  get names() {
263
281
  return this.model.names;
264
282
  }
265
- predictDrawable(data, width, height, conf, iou, classes, colormap, depthViz) {
266
- return this.model.predict_rgba(data, width, height, conf, iou, classes, colormap, depthViz);
283
+ predictDrawable(data, width, height, p) {
284
+ return this.model.predict_rgba(data, width, height, p.conf, p.iou, p.classes, p.colormap, p.depthViz);
267
285
  }
268
- predictEncoded(bytes, conf, iou, classes, colormap, depthViz) {
269
- return this.model.predict(bytes, conf, iou, classes, colormap, depthViz);
286
+ predictEncoded(bytes, p) {
287
+ return this.model.predict(bytes, p.conf, p.iou, p.classes, p.colormap, p.depthViz);
270
288
  }
271
289
  free() {
272
290
  this.model.free();
@@ -293,30 +311,30 @@ class LiteRtEngine {
293
311
  get names() {
294
312
  return this.pipeline.names;
295
313
  }
296
- predictDrawable(data, width, height, conf, iou, classes, colormap, depthViz) {
297
- return this.serialize(() => this.runDrawable(data, width, height, conf, iou, classes, colormap, depthViz));
314
+ predictDrawable(data, width, height, p) {
315
+ return this.serialize(() => this.runDrawable(data, width, height, p));
298
316
  }
299
317
  /** LiteRT takes raw pixels, so decode encoded inputs to RGBA in JS first. */
300
- predictEncoded(bytes, conf, iou, classes, colormap, depthViz) {
318
+ predictEncoded(bytes, p) {
301
319
  return this.serialize(async () => {
302
320
  const bitmap = await createImageBitmap(new Blob([bytes]));
303
321
  try {
304
322
  const { data, width, height } = toImageData(bitmap);
305
- return await this.runDrawable(data, width, height, conf, iou, classes, colormap, depthViz);
323
+ return await this.runDrawable(data, width, height, p);
306
324
  }
307
325
  finally {
308
326
  bitmap.close();
309
327
  }
310
328
  });
311
329
  }
312
- async runDrawable(data, width, height, conf, iou, classes, colormap, depthViz) {
330
+ async runDrawable(data, width, height, p) {
313
331
  const input = this.pipeline.preprocess_rgba(data, width, height);
314
332
  const { outputs, shapes, inferenceMs } = await this.backend.run(input, Array.from(this.pipeline.inputShape));
315
333
  // Flatten shapes as [rank, dims..., rank, dims...] for the wasm boundary.
316
334
  const flatShapes = [];
317
335
  for (const s of shapes)
318
336
  flatShapes.push(s.length, ...s);
319
- return this.pipeline.postprocess(outputs, new Uint32Array(flatShapes), inferenceMs, conf, iou, classes, colormap, depthViz);
337
+ return this.pipeline.postprocess(outputs, new Uint32Array(flatShapes), inferenceMs, p.conf, p.iou, p.classes, p.colormap, p.depthViz);
320
338
  }
321
339
  /** Chain `fn` after any in-flight prediction so wasm frame state is never shared. */
322
340
  serialize(fn) {
@@ -376,13 +394,13 @@ export class YOLO {
376
394
  // Honor `device` including `"auto"`, which feature-detects WebGPU (so a
377
395
  // browser without it goes straight to wasm instead of a failed compile).
378
396
  let accelerator = (await resolveDevice(options?.device)) === "webgpu" ? "webgpu" : "wasm";
379
- // End-to-end exports (YOLO26) do NMS/top-k with int64 + gather_nd ops the
397
+ // NMS-free exports (YOLO26, `nms=False`) do top-k selection with int64 + gather_nd ops the
380
398
  // LiteRT WebGPU delegate cannot run: it fails to invoke and returns zeros.
381
399
  // Force CPU/wasm so the model works. For WebGPU speed, re-export the model
382
- // with `end2end=False` so the standard head (with NMS in Rust) is used.
400
+ // with Ultralytics >=8.4.142 and `nms=None` for the one-to-many head (NMS in Rust).
383
401
  if (accelerator === "webgpu" && pipeline.end2end) {
384
402
  accelerator = "wasm";
385
- console.warn("LiteRT: this is an end2end (NMS-free) model; its WebGPU delegate can't run the int64 ops, so it runs on CPU/wasm. Re-export with `end2end=False` for WebGPU.");
403
+ 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.");
386
404
  }
387
405
  const backend = await LiteRtBackend.load(tflite, wasmUrl, accelerator);
388
406
  // The compiled model outranks the metadata: `pipeline.inputShape` is what sizes the
@@ -398,7 +416,7 @@ export class YOLO {
398
416
  get task() {
399
417
  return this.engine.task;
400
418
  }
401
- /** The active device that ran inference (`"webgpu"`, `"wasm"`, or `"cpu"`). */
419
+ /** The active device that ran inference (`"webgpu"` or `"cpu"`). */
402
420
  get device() {
403
421
  return this.engine.device;
404
422
  }
@@ -415,22 +433,24 @@ export class YOLO {
415
433
  * are decoded (in wasm for `ort`, via a canvas for `litert`).
416
434
  *
417
435
  * @param image The image to run on.
418
- * @param options Confidence/IoU thresholds.
436
+ * @param options Confidence/IoU thresholds, class filter, and depth colorizing.
419
437
  */
420
438
  async predict(image, options) {
421
- const conf = options?.conf ?? DEFAULT_CONF;
422
- const iou = options?.iou ?? DEFAULT_IOU;
423
- const classes = options?.classes ? new Uint32Array(options.classes) : undefined;
424
- // Empty means "unset": the wasm side falls back to the Rust `Colormap`/`DepthViz`
425
- // defaults, so the default lives in exactly one place.
426
- const colormap = options?.colormap ?? "";
427
- const depthViz = options?.depthViz ?? "";
439
+ const p = {
440
+ conf: options?.conf ?? DEFAULT_CONF,
441
+ iou: options?.iou ?? DEFAULT_IOU,
442
+ classes: options?.classes ? new Uint32Array(options.classes) : undefined,
443
+ // Empty means "unset": the wasm side falls back to the Rust `Colormap`/`DepthViz`
444
+ // defaults, so the default lives in exactly one place.
445
+ colormap: options?.colormap ?? "",
446
+ depthViz: options?.depthViz ?? "",
447
+ };
428
448
  if (isDrawable(image)) {
429
449
  const { data, width, height } = toImageData(image);
430
- return decodeResults(await this.engine.predictDrawable(data, width, height, conf, iou, classes, colormap, depthViz));
450
+ return decodeResults(await this.engine.predictDrawable(data, width, height, p));
431
451
  }
432
452
  const bytes = await toEncodedBytes(image);
433
- return decodeResults(await this.engine.predictEncoded(bytes, conf, iou, classes, colormap, depthViz));
453
+ return decodeResults(await this.engine.predictEncoded(bytes, p));
434
454
  }
435
455
  /** Release the underlying wasm model/engine. Call when you are done with it. */
436
456
  free() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultralytics/yolo",
3
- "version": "0.0.40",
3
+ "version": "0.0.42",
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.40",
5
+ "version": "0.0.42",
6
6
  "license": "AGPL-3.0",
7
7
  "repository": {
8
8
  "type": "git",
@@ -140,8 +140,8 @@ export class YoloPipeline {
140
140
  */
141
141
  setInputShape(shape: Int32Array): void;
142
142
  /**
143
- * Whether this is an end-to-end (NMS-free) export, e.g. YOLO26. Its head runs
144
- * the NMS/top-k with `int64`/`gather_nd` ops that the LiteRT WebGPU delegate
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
145
  * cannot execute, so such models must run on the CPU (wasm) accelerator.
146
146
  */
147
147
  readonly end2end: boolean;
@@ -200,10 +200,10 @@ export interface InitOutput {
200
200
  readonly yolopipeline_setInputShape: (a: number, b: number, c: number) => void;
201
201
  readonly yolopipeline_task: (a: number, b: number) => void;
202
202
  readonly start: () => void;
203
- readonly __wasm_bindgen_func_elem_1984: (a: number, b: number, c: number, d: number) => void;
204
- readonly __wasm_bindgen_func_elem_2589: (a: number, b: number, c: number, d: number) => void;
205
- readonly __wasm_bindgen_func_elem_1984_2: (a: number, b: number, c: number, d: number) => void;
206
- readonly __wasm_bindgen_func_elem_2613: (a: number, b: number, c: number, d: number) => void;
203
+ readonly __wasm_bindgen_func_elem_1987: (a: number, b: number, c: number, d: number) => void;
204
+ readonly __wasm_bindgen_func_elem_2594: (a: number, b: number, c: number, d: number) => void;
205
+ readonly __wasm_bindgen_func_elem_1987_2: (a: number, b: number, c: number, d: number) => void;
206
+ readonly __wasm_bindgen_func_elem_2618: (a: number, b: number, c: number, d: number) => void;
207
207
  readonly __wbindgen_export: (a: number, b: number) => number;
208
208
  readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
209
209
  readonly __wbindgen_export3: (a: number) => void;
@@ -208,8 +208,8 @@ export class YoloPipeline {
208
208
  wasm.__wbg_yolopipeline_free(ptr, 0);
209
209
  }
210
210
  /**
211
- * Whether this is an end-to-end (NMS-free) export, e.g. YOLO26. Its head runs
212
- * the NMS/top-k with `int64`/`gather_nd` ops that the LiteRT WebGPU delegate
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
213
  * cannot execute, so such models must run on the CPU (wasm) accelerator.
214
214
  * @returns {boolean}
215
215
  */
@@ -734,7 +734,7 @@ function __wbg_get_imports() {
734
734
  const a = state0.a;
735
735
  state0.a = 0;
736
736
  try {
737
- return __wasm_bindgen_func_elem_2613(a, state0.b, arg0, arg1);
737
+ return __wasm_bindgen_func_elem_2618(a, state0.b, arg0, arg1);
738
738
  } finally {
739
739
  state0.a = a;
740
740
  }
@@ -924,18 +924,18 @@ function __wbg_get_imports() {
924
924
  return addHeapObject(ret);
925
925
  },
926
926
  __wbindgen_cast_0000000000000001: function(arg0, arg1) {
927
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 689, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
928
- const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_1984);
927
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 693, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
928
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_1987);
929
929
  return addHeapObject(ret);
930
930
  },
931
931
  __wbindgen_cast_0000000000000002: function(arg0, arg1) {
932
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 917, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
933
- const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_2589);
932
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 921, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
933
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_2594);
934
934
  return addHeapObject(ret);
935
935
  },
936
936
  __wbindgen_cast_0000000000000003: function(arg0, arg1) {
937
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("boolean")], shim_idx: 689, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
938
- const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_1984_2);
937
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("boolean")], shim_idx: 693, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
938
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_1987_2);
939
939
  return addHeapObject(ret);
940
940
  },
941
941
  __wbindgen_cast_0000000000000004: function(arg0) {
@@ -1022,10 +1022,10 @@ function __wbg_get_imports() {
1022
1022
  };
1023
1023
  }
1024
1024
 
1025
- function __wasm_bindgen_func_elem_1984(arg0, arg1, arg2) {
1025
+ function __wasm_bindgen_func_elem_1987(arg0, arg1, arg2) {
1026
1026
  try {
1027
1027
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1028
- wasm.__wasm_bindgen_func_elem_1984(retptr, arg0, arg1, addHeapObject(arg2));
1028
+ wasm.__wasm_bindgen_func_elem_1987(retptr, arg0, arg1, addHeapObject(arg2));
1029
1029
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1030
1030
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1031
1031
  if (r1) {
@@ -1036,10 +1036,10 @@ function __wasm_bindgen_func_elem_1984(arg0, arg1, arg2) {
1036
1036
  }
1037
1037
  }
1038
1038
 
1039
- function __wasm_bindgen_func_elem_2589(arg0, arg1, arg2) {
1039
+ function __wasm_bindgen_func_elem_2594(arg0, arg1, arg2) {
1040
1040
  try {
1041
1041
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1042
- wasm.__wasm_bindgen_func_elem_2589(retptr, arg0, arg1, addHeapObject(arg2));
1042
+ wasm.__wasm_bindgen_func_elem_2594(retptr, arg0, arg1, addHeapObject(arg2));
1043
1043
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1044
1044
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1045
1045
  if (r1) {
@@ -1050,10 +1050,10 @@ function __wasm_bindgen_func_elem_2589(arg0, arg1, arg2) {
1050
1050
  }
1051
1051
  }
1052
1052
 
1053
- function __wasm_bindgen_func_elem_1984_2(arg0, arg1, arg2) {
1053
+ function __wasm_bindgen_func_elem_1987_2(arg0, arg1, arg2) {
1054
1054
  try {
1055
1055
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1056
- wasm.__wasm_bindgen_func_elem_1984_2(retptr, arg0, arg1, addHeapObject(arg2));
1056
+ wasm.__wasm_bindgen_func_elem_1987_2(retptr, arg0, arg1, addHeapObject(arg2));
1057
1057
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1058
1058
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1059
1059
  if (r1) {
@@ -1064,8 +1064,8 @@ function __wasm_bindgen_func_elem_1984_2(arg0, arg1, arg2) {
1064
1064
  }
1065
1065
  }
1066
1066
 
1067
- function __wasm_bindgen_func_elem_2613(arg0, arg1, arg2, arg3) {
1068
- wasm.__wasm_bindgen_func_elem_2613(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
1067
+ function __wasm_bindgen_func_elem_2618(arg0, arg1, arg2, arg3) {
1068
+ wasm.__wasm_bindgen_func_elem_2618(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
1069
1069
  }
1070
1070
 
1071
1071
 
@@ -19,10 +19,10 @@ export const yolopipeline_preprocess_rgba: (a: number, b: number, c: number, d:
19
19
  export const yolopipeline_setInputShape: (a: number, b: number, c: number) => void;
20
20
  export const yolopipeline_task: (a: number, b: number) => void;
21
21
  export const start: () => void;
22
- export const __wasm_bindgen_func_elem_1984: (a: number, b: number, c: number, d: number) => void;
23
- export const __wasm_bindgen_func_elem_2589: (a: number, b: number, c: number, d: number) => void;
24
- export const __wasm_bindgen_func_elem_1984_2: (a: number, b: number, c: number, d: number) => void;
25
- export const __wasm_bindgen_func_elem_2613: (a: number, b: number, c: number, d: number) => void;
22
+ export const __wasm_bindgen_func_elem_1987: (a: number, b: number, c: number, d: number) => void;
23
+ export const __wasm_bindgen_func_elem_2594: (a: number, b: number, c: number, d: number) => void;
24
+ export const __wasm_bindgen_func_elem_1987_2: (a: number, b: number, c: number, d: number) => void;
25
+ export const __wasm_bindgen_func_elem_2618: (a: number, b: number, c: number, d: number) => void;
26
26
  export const __wbindgen_export: (a: number, b: number) => number;
27
27
  export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
28
28
  export const __wbindgen_export3: (a: number) => void;