@ultralytics/yolo 0.0.59 → 0.0.61

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,7 +32,7 @@
32
32
 
33
33
  </div>
34
34
 
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), [semantic segmentation](https://docs.ultralytics.com/tasks/semantic), [depth estimation](https://docs.ultralytics.com/tasks/depth), [image classification](https://docs.ultralytics.com/tasks/classify), [pose estimation](https://docs.ultralytics.com/tasks/pose), and [oriented bounding boxes](https://docs.ultralytics.com/tasks/obb), behind a small TypeScript API with a built-in `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), [semantic segmentation](https://docs.ultralytics.com/tasks/semantic), [depth estimation](https://docs.ultralytics.com/tasks/depth), [image classification](https://docs.ultralytics.com/tasks/classify), [pose estimation](https://docs.ultralytics.com/tasks/pose), and [oriented object detection](https://docs.ultralytics.com/tasks/obb), and can [track](https://docs.ultralytics.com/modes/track) detected objects across video frames, behind a small TypeScript API with a built-in `annotate()` that draws results straight to a canvas.
36
36
 
37
37
  ```ts
38
38
  import { YOLO, annotate } from "@ultralytics/yolo";
@@ -113,6 +113,46 @@ async function frame() {
113
113
  }
114
114
  ```
115
115
 
116
+ ### Tracking
117
+
118
+ `track()` follows objects across video frames like Ultralytics `model.track(persist=True)`. Each call takes one frame,
119
+ in any form `predict()` accepts, and the tracker lives in the model between calls, so every tracked box gets an `id` that
120
+ carries over from frame to frame. It works for ONNX and LiteRT detection, segmentation, pose and OBB models, on a
121
+ webcam, a video or any other frame source:
122
+
123
+ ```ts
124
+ const model = await YOLO.load("/models/yolo26n.onnx");
125
+ video.srcObject = await navigator.mediaDevices.getUserMedia({ video: true }); // or video.src = "clip.mp4"
126
+ await video.play();
127
+
128
+ async function frame() {
129
+ const image = await createImageBitmap(video); // draw the same frame that was tracked
130
+ const results = await model.track(image, { tracker: "tracktrack.yaml" });
131
+ console.log(results.boxes.map((box) => box.id));
132
+ await annotate(canvas, image, results); // labels read "id:1 person 87%"
133
+ image.close();
134
+ requestAnimationFrame(frame);
135
+ }
136
+ frame();
137
+ ```
138
+
139
+ - `tracker` is `botsort.yaml`, `bytetrack.yaml`, `ocsort.yaml`, `deepocsort.yaml`, `fasttrack.yaml` or
140
+ `tracktrack.yaml` (default), each with its Ultralytics default settings. Switching to another tracker starts new tracks.
141
+ - The other options are those of `predict()`, except that `conf` defaults to `0.1` as in Ultralytics, so low-confidence
142
+ boxes can keep a track alive. A new track needs a box above the tracker's `new_track_thresh`: `0.25`, or `0.3` for
143
+ `deepocsort.yaml` and `0.7` for `tracktrack.yaml`.
144
+ - Only boxes that belong to a track are returned, except that a frame with no track to show keeps its boxes without
145
+ `id`, as in Ultralytics. `obb` gets `id` the same way, and segmentation masks and pose
146
+ keypoints follow the kept boxes.
147
+ - `model.resetTracker()` forgets every track. Call it before a new video, and between unrelated images: a single image
148
+ works too, but on its own it only numbers the objects `1..N`.
149
+ - Semantic segmentation, depth and classification models have nothing to track and return what `predict()` returns.
150
+ - `botsort.yaml` and `tracktrack.yaml` (the default) estimate camera motion with sparse optical flow, which adds about 6
151
+ to 9 ms per frame in wasm. The other trackers add under 0.1 ms, so `bytetrack.yaml` is the lightest choice for a live
152
+ webcam.
153
+ - ReID appearance matching runs only in the native crate, and is off by default in Ultralytics too. Custom tracker YAML
154
+ files are native only as well.
155
+
116
156
  ## ✨ Models
117
157
 
118
158
  <a href="https://docs.ultralytics.com/tasks" target="_blank">
@@ -142,15 +182,15 @@ GitHub release assets send no `Access-Control-Allow-Origin`, so a browser cannot
142
182
 
143
183
  ## 📐 Results Shape
144
184
 
145
- `predict()` resolves to a `Results` object whose field names match the
146
- Rust/Ultralytics `Results` API one-to-one:
185
+ `predict()` and `track()` resolve to a `Results` object whose field names match the
186
+ Rust/Ultralytics `Results` API one-to-one, with `id` set by `track()`:
147
187
 
148
188
  | Field | Type | Tasks |
149
189
  | ------------------ | -------------------------------------------------------------------- | --------------------- |
150
190
  | `task` | `string` | all |
151
191
  | `width` / `height` | `number` | all |
152
- | `boxes` | `{ x1, y1, x2, y2, conf, cls, name, color }[]` | detect, segment, pose |
153
- | `obb` | `{ x, y, w, h, angle, conf, cls, name, color }[]` | obb |
192
+ | `boxes` | `{ x1, y1, x2, y2, id?, conf, cls, name, color }[]` | detect, segment, pose |
193
+ | `obb` | `{ x, y, w, h, angle, id?, conf, cls, name, color }[]` | obb |
154
194
  | `keypoints` | `{ points: [x, y, conf][], color }[]` | pose |
155
195
  | `probs` | `{ top1, top5, top1conf, top5conf, name, top5names, color } \| null` | classify |
156
196
  | `masks` | `Uint8Array` (RGBA overlay, `width*height*4`) | segment, semantic |
package/README.zh-CN.md CHANGED
@@ -32,7 +32,7 @@
32
32
 
33
33
  </div>
34
34
 
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/semantic)、[深度估计](https://docs.ultralytics.com/tasks/depth)、[图像分类](https://docs.ultralytics.com/tasks/classify)、[姿态估计](https://docs.ultralytics.com/tasks/pose)和[旋转边界框](https://docs.ultralytics.com/tasks/obb),接口是一个小巧的 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/semantic)、[深度估计](https://docs.ultralytics.com/tasks/depth)、[图像分类](https://docs.ultralytics.com/tasks/classify)、[姿态估计](https://docs.ultralytics.com/tasks/pose)和[定向目标检测](https://docs.ultralytics.com/tasks/obb),并可在视频帧间[跟踪](https://docs.ultralytics.com/modes/track)已检测到的目标,接口是一个小巧的 TypeScript API,内置的 `annotate()` 可直接把结果绘制到 canvas 上。
36
36
 
37
37
  ```ts
38
38
  import { YOLO, annotate } from "@ultralytics/yolo";
@@ -109,6 +109,40 @@ async function frame() {
109
109
  }
110
110
  ```
111
111
 
112
+ ### 目标跟踪
113
+
114
+ `track()` 像 Ultralytics 的 `model.track(persist=True)` 一样跨视频帧跟踪目标。每次调用处理一帧,输入形式与 `predict()`
115
+ 相同;跟踪器在多次调用之间保存在模型中,因此每个被跟踪的框都会获得一个跨帧延续的 `id`。它适用于 ONNX 和 LiteRT
116
+ 的检测、分割、姿态和 OBB 模型,可用于摄像头、视频或任何其他帧来源:
117
+
118
+ ```ts
119
+ const model = await YOLO.load("/models/yolo26n.onnx");
120
+ video.srcObject = await navigator.mediaDevices.getUserMedia({ video: true }); // 或 video.src = "clip.mp4"
121
+ await video.play();
122
+
123
+ async function frame() {
124
+ const image = await createImageBitmap(video); // 绘制的正是被跟踪的那一帧
125
+ const results = await model.track(image, { tracker: "tracktrack.yaml" });
126
+ console.log(results.boxes.map((box) => box.id));
127
+ await annotate(canvas, image, results); // 标签显示为 "id:1 person 87%"
128
+ image.close();
129
+ requestAnimationFrame(frame);
130
+ }
131
+ frame();
132
+ ```
133
+
134
+ - `tracker` 可选 `botsort.yaml`、`bytetrack.yaml`、`ocsort.yaml`、`deepocsort.yaml`、`fasttrack.yaml` 或
135
+ `tracktrack.yaml`(默认),均使用 Ultralytics 的默认设置。切换到其他跟踪器会开始新的轨迹。
136
+ - 其他选项与 `predict()` 相同,但 `conf` 与 Ultralytics 一样默认为 `0.1`,使低置信度的框也能维持已有轨迹。新轨迹需要框的
137
+ 置信度高于跟踪器的 `new_track_thresh`:`0.25`,`deepocsort.yaml` 为 `0.3`,`tracktrack.yaml` 为 `0.7`。
138
+ - 只返回属于某条轨迹的框;与 Ultralytics 一样,没有可显示轨迹的帧会保留其框但不带 `id`。`obb` 同样带有 `id`,分割掩码和姿态关键点跟随保留的框。
139
+ - `model.resetTracker()` 会清除所有轨迹。处理新视频前,以及在互不相关的图片之间请调用它:单张图片也可以跟踪,但单独使用时
140
+ 只会把目标编号为 `1..N`。
141
+ - 语义分割、深度和分类模型没有可跟踪的目标,返回与 `predict()` 相同的结果。
142
+ - `botsort.yaml` 和 `tracktrack.yaml`(默认)用稀疏光流估计相机运动,在 wasm 中每帧增加约 6 到 9 ms。
143
+ 其他跟踪器增加不到 0.1 ms,因此实时摄像头最轻量的选择是 `bytetrack.yaml`。
144
+ - ReID 外观匹配只在原生 crate 中运行,在 Ultralytics 中也默认关闭。自定义跟踪器 YAML 文件同样只支持原生 crate。
145
+
112
146
  ## ✨ 模型
113
147
 
114
148
  <a href="https://docs.ultralytics.com/tasks" target="_blank">
@@ -138,14 +172,14 @@ GitHub release 资源不会返回 `Access-Control-Allow-Origin`,因此浏览
138
172
 
139
173
  ## 📐 结果结构
140
174
 
141
- `predict()` 返回的 `Results` 对象,其字段名与 Rust/Ultralytics 的 `Results` API 一一对应:
175
+ `predict()` 和 `track()` 返回的 `Results` 对象,其字段名与 Rust/Ultralytics 的 `Results` API 一一对应,`id` 由 `track()` 设置:
142
176
 
143
177
  | 字段 | 类型 | 任务 |
144
178
  | ------------------ | -------------------------------------------------------------------- | --------------------- |
145
179
  | `task` | `string` | 全部 |
146
180
  | `width` / `height` | `number` | 全部 |
147
- | `boxes` | `{ x1, y1, x2, y2, conf, cls, name, color }[]` | detect、segment、pose |
148
- | `obb` | `{ x, y, w, h, angle, conf, cls, name, color }[]` | obb |
181
+ | `boxes` | `{ x1, y1, x2, y2, id?, conf, cls, name, color }[]` | detect、segment、pose |
182
+ | `obb` | `{ x, y, w, h, angle, id?, conf, cls, name, color }[]` | obb |
149
183
  | `keypoints` | `{ points: [x, y, conf][], color }[]` | pose |
150
184
  | `probs` | `{ top1, top5, top1conf, top5conf, name, top5names, color } \| null` | classify |
151
185
  | `masks` | `Uint8Array`(RGBA 叠加层,`width*height*4`) | segment、semantic |
package/dist/index.d.ts CHANGED
@@ -4,6 +4,8 @@ export interface Box {
4
4
  y1: number;
5
5
  x2: number;
6
6
  y2: number;
7
+ /** Track id, set by {@link YOLO.track}. */
8
+ id?: number;
7
9
  conf: number;
8
10
  cls: number;
9
11
  name: string;
@@ -16,6 +18,8 @@ export interface Obb {
16
18
  w: number;
17
19
  h: number;
18
20
  angle: number;
21
+ /** Track id, set by {@link YOLO.track}. */
22
+ id?: number;
19
23
  conf: number;
20
24
  cls: number;
21
25
  name: string;
@@ -131,13 +135,21 @@ export interface PredictOptions {
131
135
  */
132
136
  depthViz?: "metric" | "disparity";
133
137
  }
138
+ /** Options for {@link YOLO.track}. */
139
+ export interface TrackOptions extends PredictOptions {
140
+ /**
141
+ * Tracker: `"botsort.yaml"`, `"bytetrack.yaml"`, `"ocsort.yaml"`, `"deepocsort.yaml"`, `"fasttrack.yaml"` or
142
+ * `"tracktrack.yaml"` (default, like Ultralytics). Changing it starts new tracks.
143
+ */
144
+ tracker?: string;
145
+ }
134
146
  /** Options for {@link annotate}. */
135
147
  export interface AnnotateOptions {
136
148
  /** Box/line width in pixels. Defaults to a value scaled to the image size. */
137
149
  lineWidth?: number;
138
150
  /** Font CSS string. Defaults to a size scaled to the image. */
139
151
  font?: string;
140
- /** Draw `class_name confidence%` labels. Default `true`. */
152
+ /** Draw `id:track_id class_name confidence%` labels. Default `true`. */
141
153
  labels?: boolean;
142
154
  /** Draw pose keypoints and skeleton. Default `true`. */
143
155
  keypoints?: boolean;
@@ -207,6 +219,20 @@ export declare class YOLO {
207
219
  * @param options Confidence/IoU thresholds, class filter, and depth colorizing.
208
220
  */
209
221
  predict(image: ImageInput, options?: PredictOptions): Promise<Results>;
222
+ /**
223
+ * Run inference on the next frame of a video and track its objects, like Ultralytics
224
+ * `model.track(persist=True)`: tracks carry over between calls and every tracked box gets an
225
+ * `id` (a frame with no track to show keeps its boxes without one, as in Ultralytics). Confidence defaults to `0.1` here, as in Ultralytics. Call {@link resetTracker}
226
+ * before a new video.
227
+ *
228
+ * @param image The frame to run on, as in {@link predict}.
229
+ * @param options The {@link predict} options and the tracker.
230
+ */
231
+ track(image: ImageInput, options?: TrackOptions): Promise<Results>;
232
+ /** Forget the tracks of {@link track}, so the next frame starts a new video. */
233
+ resetTracker(): void;
234
+ /** Run one prediction in turn, tracked by `tracker` when given. */
235
+ private run;
210
236
  /** Release the underlying wasm model/engine. Call when you are done with it. */
211
237
  free(): void;
212
238
  }
package/dist/index.js CHANGED
@@ -15,6 +15,10 @@
15
15
  * for (const box of results.boxes) {
16
16
  * console.log(box.name, box.conf, box.x1, box.y1, box.x2, box.y2);
17
17
  * }
18
+ *
19
+ * // Tracks carry over between calls, like `model.track(persist=True)` in Ultralytics.
20
+ * const tracked = await model.track(videoElement, { tracker: "tracktrack.yaml" });
21
+ * console.log(tracked.boxes.map((box) => box.id));
18
22
  * ```
19
23
  */
20
24
  import init, { YoloModel, YoloPipeline, start, pose_palette, bidi_runs } from "../pkg/ultralytics_inference_web.js";
@@ -295,10 +299,13 @@ class OrtEngine {
295
299
  return this.model.names;
296
300
  }
297
301
  predictDrawable(data, width, height, p) {
298
- return this.model.predict_rgba(data, width, height, p.conf, p.iou, p.classes, p.colormap, p.depthViz);
302
+ return this.model.predict_rgba(data, width, height, p.conf, p.iou, p.classes, p.colormap, p.depthViz, p.tracker);
299
303
  }
300
304
  predictEncoded(bytes, p) {
301
- return this.model.predict(bytes, p.conf, p.iou, p.classes, p.colormap, p.depthViz);
305
+ return this.model.predict(bytes, p.conf, p.iou, p.classes, p.colormap, p.depthViz, p.tracker);
306
+ }
307
+ resetTracker() {
308
+ this.model.reset_tracker();
302
309
  }
303
310
  free() {
304
311
  this.model.free();
@@ -335,7 +342,10 @@ class LiteRtEngine {
335
342
  async predictDrawable(data, width, height, p) {
336
343
  const input = this.pipeline.preprocess_rgba(data, width, height);
337
344
  const { outputs, shapes, inferenceMs } = await this.backend.run(input, Array.from(this.pipeline.inputShape));
338
- return this.pipeline.postprocess(outputs, shapes.map((s) => new Uint32Array(s)), inferenceMs, p.conf, p.iou, p.classes, p.colormap, p.depthViz);
345
+ return this.pipeline.postprocess(outputs, shapes.map((s) => new Uint32Array(s)), inferenceMs, p.conf, p.iou, p.classes, p.colormap, p.depthViz, p.tracker);
346
+ }
347
+ resetTracker() {
348
+ this.pipeline.reset_tracker();
339
349
  }
340
350
  free() {
341
351
  this.pipeline.free();
@@ -415,6 +425,26 @@ export class YOLO {
415
425
  * @param options Confidence/IoU thresholds, class filter, and depth colorizing.
416
426
  */
417
427
  async predict(image, options) {
428
+ return this.run(image, options);
429
+ }
430
+ /**
431
+ * Run inference on the next frame of a video and track its objects, like Ultralytics
432
+ * `model.track(persist=True)`: tracks carry over between calls and every tracked box gets an
433
+ * `id` (a frame with no track to show keeps its boxes without one, as in Ultralytics). Confidence defaults to `0.1` here, as in Ultralytics. Call {@link resetTracker}
434
+ * before a new video.
435
+ *
436
+ * @param image The frame to run on, as in {@link predict}.
437
+ * @param options The {@link predict} options and the tracker.
438
+ */
439
+ async track(image, options) {
440
+ return this.run(image, options, options?.tracker ?? "tracktrack.yaml");
441
+ }
442
+ /** Forget the tracks of {@link track}, so the next frame starts a new video. */
443
+ resetTracker() {
444
+ this.queue = this.queue.then(() => this.engine.resetTracker());
445
+ }
446
+ /** Run one prediction in turn, tracked by `tracker` when given. */
447
+ async run(image, options, tracker) {
418
448
  const p = {
419
449
  // Unset thresholds fall back to the Rust `InferenceConfig` defaults.
420
450
  conf: options?.conf,
@@ -424,6 +454,7 @@ export class YOLO {
424
454
  // defaults, so the default lives in exactly one place.
425
455
  colormap: options?.colormap ?? "",
426
456
  depthViz: options?.depthViz ?? "",
457
+ tracker,
427
458
  };
428
459
  let predict;
429
460
  if (isDrawable(image)) {
@@ -536,6 +567,7 @@ export async function annotate(canvas, image, results, options) {
536
567
  x += run.width;
537
568
  }
538
569
  };
570
+ const caption = (d) => `${d.id === undefined ? "" : `id:${d.id} `}${d.name} ${(d.conf * 100).toFixed(0)}%`;
539
571
  const label = (text, x, y, color) => {
540
572
  if (!showLabels)
541
573
  return;
@@ -553,7 +585,7 @@ export async function annotate(canvas, image, results, options) {
553
585
  for (const b of results.boxes) {
554
586
  ctx.strokeStyle = b.color;
555
587
  ctx.strokeRect(b.x1, b.y1, b.x2 - b.x1, b.y2 - b.y1);
556
- label(`${b.name} ${(b.conf * 100).toFixed(0)}%`, b.x1, b.y1, b.color);
588
+ label(caption(b), b.x1, b.y1, b.color);
557
589
  }
558
590
  // Oriented boxes (obb): draw the rotated rectangle.
559
591
  for (const o of results.obb) {
@@ -576,7 +608,7 @@ export async function annotate(canvas, image, results, options) {
576
608
  ctx.lineTo(corners[i][0], corners[i][1]);
577
609
  ctx.closePath();
578
610
  ctx.stroke();
579
- label(`${o.name} ${(o.conf * 100).toFixed(0)}%`, corners[0][0], corners[0][1], color);
611
+ label(caption(o), corners[0][0], corners[0][1], color);
580
612
  }
581
613
  // Pose keypoints + skeleton, colored with the engine's pose palette (per-limb
582
614
  // and per-keypoint), matching the native/Python renderer.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultralytics/yolo",
3
- "version": "0.0.59",
3
+ "version": "0.0.61",
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.59",
5
+ "version": "0.0.61",
6
6
  "license": "AGPL-3.0",
7
7
  "repository": {
8
8
  "type": "git",
@@ -29,19 +29,22 @@ export class YoloModel {
29
29
  * Returns a JS error if the backend cannot start, the bytes are not a valid
30
30
  * model, or the model lacks Ultralytics metadata.
31
31
  */
32
- static load_bytes(bytes: Uint8Array, ort_base_url: string | null | undefined, device: string): Promise<YoloModel>;
32
+ static load_bytes(bytes: Uint8Array | number[], ort_base_url: string | null | undefined, device: string): Promise<YoloModel>;
33
33
  /**
34
34
  * Run inference on a single encoded image (JPEG or PNG bytes).
35
35
  *
36
36
  * `conf` and `iou` are the confidence and NMS IoU thresholds (omit them for the
37
37
  * Ultralytics defaults 0.25 / 0.5); `classes` optionally keeps only
38
38
  * the given class ids (for semantic, other pixels become background).
39
+ * `tracker` (`"tracktrack.yaml"`, `"botsort.yaml"`, ...) tracks the detections across
40
+ * calls like Ultralytics `model.track(persist=True)`, starting anew when it changes.
39
41
  * Returns a plain JS object whose shape mirrors the Ultralytics `Results` API.
40
42
  *
41
43
  * # Errors
42
- * Returns a JS error if the image cannot be decoded or inference fails.
44
+ * Returns a JS error if the image cannot be decoded, the tracker is unknown or
45
+ * inference fails.
43
46
  */
44
- predict(image: Uint8Array, conf: number | null | undefined, iou: number | null | undefined, classes: Uint32Array | null | undefined, colormap: string, depth_viz: string): Promise<any>;
47
+ predict(image: Uint8Array | number[], conf: number | null | undefined, iou: number | null | undefined, classes: Uint32Array | number[] | null | undefined, colormap: string, depth_viz: string, tracker?: string | null): Promise<any>;
45
48
  /**
46
49
  * Run inference on raw `RGBA` pixels (e.g. a canvas/webcam `ImageData`).
47
50
  *
@@ -51,7 +54,11 @@ export class YoloModel {
51
54
  * # Errors
52
55
  * Returns a JS error if the buffer size is wrong or inference fails.
53
56
  */
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>;
57
+ predict_rgba(rgba: Uint8Array | number[], width: number, height: number, conf: number | null | undefined, iou: number | null | undefined, classes: Uint32Array | number[] | null | undefined, colormap: string, depth_viz: string, tracker?: string | null): Promise<any>;
58
+ /**
59
+ * Forget the tracks, so the next frame starts a new video.
60
+ */
61
+ reset_tracker(): void;
55
62
  /**
56
63
  * The active device: `"webgpu"` or `"cpu"` (the fallback when WebGPU is
57
64
  * unavailable). Mirrors the native `Device` display.
@@ -95,7 +102,7 @@ export class YoloPipeline {
95
102
  * Returns a JS error if the model carries no Ultralytics metadata or it
96
103
  * cannot be parsed.
97
104
  */
98
- constructor(tflite: Uint8Array);
105
+ constructor(tflite: Uint8Array | number[]);
99
106
  /**
100
107
  * Postprocess an external engine's raw outputs into the standard `Results`.
101
108
  *
@@ -103,14 +110,15 @@ export class YoloPipeline {
103
110
  * segmentation: detection head + mask prototypes), with one entry of dims per
104
111
  * output in `shapes`. `inference_ms`
105
112
  * is the time the JS engine reported, used only for the `speed` breakdown.
113
+ * `tracker` tracks the detections as in [`YoloModel::predict`].
106
114
  * Consumes the frame stashed by the preceding
107
115
  * [`preprocess_rgba`](Self::preprocess_rgba).
108
116
  *
109
117
  * # Errors
110
118
  * Returns a JS error if called before `preprocess_rgba`, if `shapes` does not
111
- * have one entry per output, or on serialization failure.
119
+ * have one entry per output, if the tracker is unknown, or on serialization failure.
112
120
  */
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;
121
+ postprocess(outputs: Float32Array[], shapes: Uint32Array[], inference_ms: number, conf: number | null | undefined, iou: number | null | undefined, classes: Uint32Array | number[] | null | undefined, colormap: string, depth_viz: string, tracker?: string | null): any;
114
122
  /**
115
123
  * Preprocess raw RGBA pixels (e.g. a webcam `ImageData`) into the NCHW f32
116
124
  * input tensor an Ultralytics LiteRT/TFLite model expects, normalized to
@@ -123,7 +131,11 @@ export class YoloPipeline {
123
131
  * # Errors
124
132
  * Returns a JS error if the buffer size is not `width * height * 4`.
125
133
  */
126
- preprocess_rgba(rgba: Uint8Array, width: number, height: number): Float32Array;
134
+ preprocess_rgba(rgba: Uint8Array | number[], width: number, height: number): Float32Array;
135
+ /**
136
+ * Forget the tracks, so the next frame starts a new video.
137
+ */
138
+ reset_tracker(): void;
127
139
  /**
128
140
  * Adopt the input shape the engine reports for the compiled model.
129
141
  *
@@ -138,7 +150,7 @@ export class YoloPipeline {
138
150
  * non-positive axis, which is how a dynamic dimension is reported, is ignored and leaves
139
151
  * the metadata size in place.
140
152
  */
141
- setInputShape(shape: Int32Array): void;
153
+ setInputShape(shape: Int32Array | number[]): void;
142
154
  /**
143
155
  * The model input shape as `[1, 3, H, W]` (NCHW), for sizing the engine's
144
156
  * input tensor. Ultralytics LiteRT exports (`ai_edge_torch`) keep the native
@@ -191,28 +203,34 @@ export interface InitOutput {
191
203
  readonly pose_palette: (a: number) => void;
192
204
  readonly start: () => void;
193
205
  readonly yolomodel_device: (a: number, b: number) => void;
194
- readonly yolomodel_load_bytes: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
206
+ readonly yolomodel_load_bytes: (a: number, b: number, c: number, d: number, e: number, f: number) => any;
195
207
  readonly yolomodel_names: (a: number, b: number) => void;
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;
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;
208
+ 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, l: number, m: number) => any;
209
+ 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, n: number, o: number) => any;
210
+ readonly yolomodel_reset_tracker: (a: number) => void;
198
211
  readonly yolomodel_task: (a: number, b: number) => void;
199
212
  readonly yolopipeline_inputShape: (a: number, b: number) => void;
200
213
  readonly yolopipeline_names: (a: number, b: number) => void;
201
214
  readonly yolopipeline_new: (a: number, b: number, c: number) => void;
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;
215
+ 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, p: number, q: number) => void;
203
216
  readonly yolopipeline_preprocess_rgba: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
217
+ readonly yolopipeline_reset_tracker: (a: number) => void;
204
218
  readonly yolopipeline_setInputShape: (a: number, b: number, c: number) => void;
205
219
  readonly yolopipeline_task: (a: number, b: number) => void;
206
- readonly __wasm_bindgen_func_elem_1236: (a: number, b: number, c: number, d: number) => void;
207
- readonly __wasm_bindgen_func_elem_1867: (a: number, b: number, c: number, d: number) => void;
208
- readonly __wasm_bindgen_func_elem_1891: (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;
220
+ readonly __wasm_bindgen_func_elem_1334: (a: number, b: number, c: number, d: any) => void;
221
+ readonly __wasm_bindgen_func_elem_1970: (a: number, b: number, c: number, d: any) => void;
222
+ readonly __wasm_bindgen_func_elem_1996: (a: number, b: number, c: any, d: any) => void;
223
+ readonly __wasm_bindgen_func_elem_397: (a: number, b: number, c: number, d: any) => void;
210
224
  readonly __wbindgen_export: (a: number, b: number) => number;
211
225
  readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
212
- readonly __wbindgen_export3: (a: number) => void;
213
- readonly __wbindgen_export4: (a: number, b: number, c: number) => void;
214
- readonly __wbindgen_export5: (a: number, b: number) => void;
226
+ readonly __wbindgen_export3: (a: number, b: number, c: number) => void;
227
+ readonly __wbindgen_export4: (a: number) => void;
228
+ readonly __wbindgen_export5: () => number;
229
+ readonly __wbindgen_externrefs: WebAssembly.Table;
230
+ readonly __wbindgen_export6: (a: number, b: number) => void;
231
+ readonly __wbindgen_export7: (a: number, b: number) => void;
215
232
  readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
233
+ readonly __wbindgen_export8: (a: number) => void;
216
234
  readonly __wbindgen_start: () => void;
217
235
  }
218
236