@ultralytics/yolo 0.0.30 → 0.0.32

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
@@ -16,8 +16,8 @@
16
16
 
17
17
  Run [Ultralytics](https://www.ultralytics.com/) YOLO models directly in the browser,
18
18
  with no server and no Python. It runs on **WebGPU** (with an automatic CPU/wasm
19
- fallback) and covers detection, segmentation, pose, classification, OBB, and
20
- semantic segmentation, behind a small TypeScript API with a built-in
19
+ fallback) and covers detection, segmentation, pose, classification, OBB,
20
+ semantic segmentation, and depth estimation, behind a small TypeScript API with a built-in
21
21
  `annotate()` that draws results straight to a canvas.
22
22
 
23
23
  ```ts
@@ -107,8 +107,14 @@ async function frame() {
107
107
 
108
108
  Runs [Ultralytics YOLOv8](https://docs.ultralytics.com/models/yolov8),
109
109
  [Ultralytics YOLO11](https://docs.ultralytics.com/models/yolo11), and
110
- [Ultralytics YOLO26](https://docs.ultralytics.com/models/yolo26) ONNX exports for detection,
111
- segmentation, pose, OBB, classification, and semantic segmentation.
110
+ [Ultralytics YOLO26](https://docs.ultralytics.com/models/yolo26) ONNX exports for
111
+ [detection](https://docs.ultralytics.com/tasks/detect),
112
+ [segmentation](https://docs.ultralytics.com/tasks/segment),
113
+ [pose](https://docs.ultralytics.com/tasks/pose),
114
+ [OBB](https://docs.ultralytics.com/tasks/obb),
115
+ [classification](https://docs.ultralytics.com/tasks/classify),
116
+ [semantic segmentation](https://docs.ultralytics.com/tasks/semantic), and
117
+ [depth estimation](https://docs.ultralytics.com/tasks/depth).
112
118
 
113
119
  Pass a bare ONNX name and it is **auto-downloaded** from the
114
120
  [Ultralytics assets release](https://github.com/ultralytics/assets/releases) (the
@@ -119,8 +125,9 @@ await YOLO.load("yolo26n.onnx"); // auto-downloads from the release: .../downloa
119
125
  ```
120
126
 
121
127
  Auto-download covers **Ultralytics YOLO26**, **Ultralytics YOLO11**, and **Ultralytics YOLOv8** in sizes `n/s/m/l/x`
122
- with task suffixes `-seg`, `-pose`, `-cls`, `-obb`, and `-sem` (semantic, Ultralytics YOLO26
123
- only). A value containing a `/` or a scheme is used as a URL/path as-is.
128
+ with task suffixes `-seg`, `-pose`, `-cls`, `-obb`, `-sem` (semantic), and `-depth` (depth
129
+ estimation) — the last two Ultralytics YOLO26 only. A value containing a `/` or a scheme is
130
+ used as a URL/path as-is.
124
131
 
125
132
  > **CORS note:** GitHub release assets do not send `Access-Control-Allow-Origin`,
126
133
  > so a browser cannot fetch them cross-origin. Host the `.onnx` **same-origin**
@@ -130,10 +137,8 @@ only). A value containing a `/` or a scheme is used as a URL/path as-is.
130
137
 
131
138
  ## 📐 Results Shape
132
139
 
133
- `predict()` resolves to a `Results` object shaped like the Ultralytics
134
- `Results`:
135
-
136
- Field names match the Rust/Ultralytics `Results` API 1-1:
140
+ `predict()` resolves to a `Results` object whose field names match the
141
+ Rust/Ultralytics `Results` API 1-1:
137
142
 
138
143
  | Field | Type | Tasks |
139
144
  | ------------------ | -------------------------------------------------------------------- | --------------------- |
@@ -145,6 +150,8 @@ Field names match the Rust/Ultralytics `Results` API 1-1:
145
150
  | `probs` | `{ top1, top5, top1conf, top5conf, name, top5names, color } \| null` | classify |
146
151
  | `masks` | `Uint8Array` (RGBA overlay, `width*height*4`) | segment, semantic |
147
152
  | `semantic_mask` | `Uint16Array` (class id per pixel, `width*height`) | semantic |
153
+ | `depth` | `Uint8Array` (opaque colorized depth map, `width*height*4`) | depth |
154
+ | `depth_range` | `[min, max]` in meters | depth |
148
155
  | `speed` | `{ preprocess, inference, postprocess }` ms | all |
149
156
 
150
157
  `model.names` is the class id to name map (like `model.names` in Python). Every
@@ -152,6 +159,16 @@ detection carries its Ultralytics palette `color`, and `annotate()` draws the
152
159
  `masks` overlay and the pose skeleton with the same per-limb/keypoint colors as
153
160
  the native renderer. None of this is duplicated in JS.
154
161
 
162
+ For the `depth` task, `predict(img, { colormap, depthViz })` picks the colormap
163
+ (`"jet"` default, `"inferno"`, `"spectral"`, `"gray"`) and normalization
164
+ (`"disparity"` default, `"metric"`); `annotate()` blends the returned map over the
165
+ frame at `depthAlpha` (default `0.6`, `1` shows the raw map):
166
+
167
+ ```ts
168
+ const results = await model.predict(img, { colormap: "spectral", depthViz: "metric" });
169
+ await annotate(canvas, img, results, { depthAlpha: 0.6 });
170
+ ```
171
+
155
172
  ## ⚙️ Requirements & Notes
156
173
 
157
174
  - **WebGPU** (Chrome/Edge, or Firefox with WebGPU enabled) from a **secure
package/dist/index.d.ts CHANGED
@@ -61,9 +61,10 @@ export interface Results {
61
61
  */
62
62
  semantic_mask?: Uint16Array;
63
63
  /**
64
- * Depth map as an opaque colorized RGBA image (`width*height*4`), using the
65
- * colormap from {@link PredictOptions.colormap}; empty for other tasks.
66
- * Drawable straight onto a canvas via `ImageData`.
64
+ * Depth map as an opaque colorized RGBA image (`width*height*4`), using the colormap
65
+ * from {@link PredictOptions.colormap}; empty for other tasks. {@link annotate} blends
66
+ * it over the frame at {@link AnnotateOptions.depthAlpha} (default 0.6); draw it directly
67
+ * for the raw map.
67
68
  */
68
69
  depth: Uint8Array;
69
70
  /** Depth range `[min, max]` in meters over valid pixels, for depth models. */
@@ -115,13 +116,13 @@ export interface PredictOptions {
115
116
  classes?: number[];
116
117
  /**
117
118
  * Depth colormap for the `depth` overlay: `"jet"` (default, classic rainbow),
118
- * `"inferno"`, `"spectral"` (`Spectral_r`, DepthAnything-style), or `"gray"` (raw
119
- * grayscale). Ignored by every other task.
119
+ * `"inferno"`, `"spectral"` (`Spectral_r`), or `"gray"` (raw grayscale). Ignored by
120
+ * every other task.
120
121
  */
121
122
  colormap?: "inferno" | "jet" | "spectral" | "gray";
122
123
  /**
123
- * Depth normalization: `"disparity"` (default, inverse depth + percentile clip, the
124
- * DepthAnything look) or `"metric"` (min/max). Ignored by every other task.
124
+ * Depth normalization: `"disparity"` (default, inverse depth + percentile clip) or
125
+ * `"metric"` (min/max). Ignored by every other task.
125
126
  */
126
127
  depthViz?: "metric" | "disparity";
127
128
  }
@@ -137,6 +138,11 @@ export interface AnnotateOptions {
137
138
  keypoints?: boolean;
138
139
  /** Keypoint confidence threshold for drawing. Default `0.25` (matches Ultralytics). */
139
140
  keypointThreshold?: number;
141
+ /**
142
+ * Blend opacity for the depth overlay, `0`..`1`. Default `0.6` (matches the native
143
+ * annotator); `1` shows the raw colorized depth map, `0` shows only the source.
144
+ */
145
+ depthAlpha?: number;
140
146
  }
141
147
  /** Image-like inputs accepted by {@link YOLO.predict}. */
142
148
  export type ImageInput = string | URL | Blob | ArrayBuffer | Uint8Array | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap;
@@ -161,7 +167,7 @@ export declare class YOLO {
161
167
  /** Load the LiteRT (`.tflite`) backend. Metadata (task, class names, `imgsz`)
162
168
  * is read from the single `.tflite` file, the same as the `.onnx` path. */
163
169
  private static loadLiteRt;
164
- /** The model's task (`detect`, `segment`, `pose`, `classify`, `obb`, `semantic`). */
170
+ /** The model's task (`detect`, `segment`, `pose`, `classify`, `obb`, `semantic`, `depth`). */
165
171
  get task(): string;
166
172
  /** The active device that ran inference (`"webgpu"`, `"wasm"`, or `"cpu"`). */
167
173
  get device(): string;
package/dist/index.js CHANGED
@@ -205,6 +205,11 @@ class LiteRtBackend {
205
205
  this.model = model;
206
206
  this.device = device;
207
207
  }
208
+ /** Input shape the compiled model actually expects, when LiteRT reports it. */
209
+ get inputShape() {
210
+ const shape = this.model.getInputDetails?.()[0]?.shape;
211
+ return shape && Array.from(shape);
212
+ }
208
213
  /** Import LiteRT.js, init its wasm, and compile the model, falling back from
209
214
  * WebGPU to wasm (CPU) if the GPU accelerator cannot compile. */
210
215
  static async load(tflite, wasmUrl, accelerator) {
@@ -393,9 +398,16 @@ export class YOLO {
393
398
  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.");
394
399
  }
395
400
  const backend = await LiteRtBackend.load(tflite, wasmUrl, accelerator);
401
+ // The compiled model outranks the metadata: `pipeline.inputShape` is what sizes the
402
+ // input tensor below, so a stale `imgsz` would build one the model rejects.
403
+ // Signed on purpose: the engine reports a dynamic axis as a negative number, and wasm
404
+ // rejects those rather than reading one as a huge unsigned size.
405
+ const shape = backend.inputShape;
406
+ if (shape)
407
+ pipeline.setInputShape(new Int32Array(shape));
396
408
  return new YOLO(new LiteRtEngine(pipeline, backend));
397
409
  }
398
- /** The model's task (`detect`, `segment`, `pose`, `classify`, `obb`, `semantic`). */
410
+ /** The model's task (`detect`, `segment`, `pose`, `classify`, `obb`, `semantic`, `depth`). */
399
411
  get task() {
400
412
  return this.engine.task;
401
413
  }
@@ -480,13 +492,17 @@ export async function annotate(canvas, image, results, options) {
480
492
  get2d(tmp).putImageData(new ImageData(new Uint8ClampedArray(overlay), width, height), 0, 0);
481
493
  ctx.drawImage(tmp, 0, 0, width, height);
482
494
  }
483
- // Depth: the engine returns an opaque colorized depth image; draw it over the
484
- // frame so the canvas shows the depth map.
495
+ // Depth: the engine returns the opaque colorized depth map, blended over the frame here
496
+ // at `depthAlpha` (default 0.6; pass 1 for the raw map, 0 for none). Like the segment
497
+ // overlay above, this assumes an opaque source (photo/camera/video frame): a source with
498
+ // transparent pixels keeps that transparency through the blend.
485
499
  const depth = results.depth;
486
500
  if (depth && depth.length === width * height * 4) {
487
501
  const tmp = makeCanvas(width, height);
488
502
  get2d(tmp).putImageData(new ImageData(new Uint8ClampedArray(depth), width, height), 0, 0);
503
+ ctx.globalAlpha = options?.depthAlpha ?? 0.6;
489
504
  ctx.drawImage(tmp, 0, 0, width, height);
505
+ ctx.globalAlpha = 1;
490
506
  }
491
507
  const lineWidth = options?.lineWidth ?? Math.max(2, Math.round(width / 320));
492
508
  const fontSize = Math.max(12, Math.round(width / 40));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultralytics/yolo",
3
- "version": "0.0.30",
3
+ "version": "0.0.32",
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",
@@ -66,7 +66,7 @@
66
66
  }
67
67
  },
68
68
  "devDependencies": {
69
- "@litertjs/core": "^2.5.0",
69
+ "@litertjs/core": "^2.5.3",
70
70
  "typescript": "^5.4.0"
71
71
  }
72
72
  }
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.30",
5
+ "version": "0.0.32",
6
6
  "license": "AGPL-3.0",
7
7
  "repository": {
8
8
  "type": "git",
@@ -14,7 +14,7 @@ const FEATURES_ALL = FEATURES_WEBGL | FEATURES_WEBGPU;
14
14
  * @property {Record<'main' | 'wrapper' | 'binary', string> | null} integrities
15
15
  */
16
16
 
17
- const DEFAULT_DIST_BASE = 'https://cdn.pyke.io/0/pyke:ort-rs/web@1.24.3/';
17
+ const DEFAULT_DIST_BASE = 'https://cdn.pyke.io/0/pyke:ort-rs/web@1.27.0/';
18
18
 
19
19
  /** @type {Record<number, Dist>} */
20
20
  const DEFAULT_DIST = {
@@ -23,9 +23,9 @@ const DEFAULT_DIST = {
23
23
  scriptName: 'ort.wasm.min.js',
24
24
  binaryName: 'ort-wasm-simd-threaded.wasm',
25
25
  integrities: {
26
- main: '1SBQgvQsxJRGAOAJ6K2nPaLO1SKelZwoF+biXgv2/D9fPspYLhvG4WIMDb/BUoJC',
27
- wrapper: '/xM/eq8aUBJZgBuVwTQcLA5KlNmP6HOaENdJVgCkA/06cOMdL9EIQtmMuXOlMZEd',
28
- binary: 'sZw0EVBgUn+dNhQfjHDg8lwtmicKMm1bTvWS4rIRNxoVN1S9HkVyJ2nreMpYruEZ'
26
+ main: 'tfUvHgp9/GSRWo8HC27M+k72kO9DXscoOHJVFMMo17my+b613YTj9vpom0og1Cwe',
27
+ wrapper: 'QwBuCPwkZ1hn48SSG/YP1rd25hKczDIg103x2AtlotnwUzVF919IZz1uRnLp9IOw',
28
+ binary: 'ZBv2MGQL3EUHCYbVm9I410F+QZX7GWFj9a556jISGqlE2TiRaeEWLu6jxd8ZYMGC'
29
29
  }
30
30
  },
31
31
  [FEATURES_WEBGL]: {
@@ -33,9 +33,9 @@ const DEFAULT_DIST = {
33
33
  scriptName: 'ort.webgl.min.js',
34
34
  binaryName: 'ort-wasm-simd-threaded.wasm',
35
35
  integrities: {
36
- main: 'tBplgcsp8KUmgpc7glC4gbb5MdN/LBa1x90w++Y5WHDLaLo0m75wK+OtxIVa0KB6',
37
- wrapper: '/xM/eq8aUBJZgBuVwTQcLA5KlNmP6HOaENdJVgCkA/06cOMdL9EIQtmMuXOlMZEd',
38
- binary: 'sZw0EVBgUn+dNhQfjHDg8lwtmicKMm1bTvWS4rIRNxoVN1S9HkVyJ2nreMpYruEZ'
36
+ main: 'LXzScLvNEhm413eMpAqQVWHzPW+FRbGjfJ+u33IO6bHCV8rfBfd2eGdAwpKAdvIQ',
37
+ wrapper: 'QwBuCPwkZ1hn48SSG/YP1rd25hKczDIg103x2AtlotnwUzVF919IZz1uRnLp9IOw',
38
+ binary: 'ZBv2MGQL3EUHCYbVm9I410F+QZX7GWFj9a556jISGqlE2TiRaeEWLu6jxd8ZYMGC'
39
39
  }
40
40
  },
41
41
  [FEATURES_WEBGPU]: {
@@ -43,9 +43,9 @@ const DEFAULT_DIST = {
43
43
  scriptName: 'ort.webgpu.min.js',
44
44
  binaryName: 'ort-wasm-simd-threaded.jsep.wasm',
45
45
  integrities: {
46
- main: 'ryEl5/BLEvDIrNfBZGTpwZzs0EFe+rDt9wM/Xs5DbM7mwJm2V6/BPE7AGVtwKKiL',
47
- wrapper: 'C9DMcnZCIFFbpwJbX9QrGnrhpRt+2yD/FCcEZRrYf0iuzpOlCibPY0zsN8Wh1O+U',
48
- binary: 'SLG1FQY8ZmHhts4OFaia4WTuj6Ttjqb3U7uJQXb8L19O+HB0DG8zJh+vdmXdxD53'
46
+ main: 'vRrDQHAbl9gWevu3ErZ/gXohErGlZmJy4wyowACQUyuTXCTWAgX8fpBBg70OGWVv',
47
+ wrapper: 'UnMnZc4hekoMygc89hIyX3b7KuuNwqJTMOZJdeAQjuvGC/WVdTT+w+HmwWCANfli',
48
+ binary: 'NRkAqXy32zY6LuDA4go2FTF1Cy85jvEfSu6DPTevOmSu441+7WhVZocyqdhT1kNB'
49
49
  }
50
50
  },
51
51
  [FEATURES_ALL]: {
@@ -53,9 +53,9 @@ const DEFAULT_DIST = {
53
53
  scriptName: 'ort.all.min.js',
54
54
  binaryName: 'ort-wasm-simd-threaded.jsep.wasm',
55
55
  integrities: {
56
- main: 'aSKRQamw4Hf1ggcSUR2ZFriC21oCir1YibdErfC+xmh/w1ijdn/GP4Vr4rMu1dvs',
57
- wrapper: 'C9DMcnZCIFFbpwJbX9QrGnrhpRt+2yD/FCcEZRrYf0iuzpOlCibPY0zsN8Wh1O+U',
58
- binary: 'SLG1FQY8ZmHhts4OFaia4WTuj6Ttjqb3U7uJQXb8L19O+HB0DG8zJh+vdmXdxD53'
56
+ main: 'PbfZfzjTjLQV5yWsBfBwAOzKd0qqPbvuTgfGZfgg+7lQQM8HvS3E0M4mYM1kD4zq',
57
+ wrapper: 'UnMnZc4hekoMygc89hIyX3b7KuuNwqJTMOZJdeAQjuvGC/WVdTT+w+HmwWCANfli',
58
+ binary: 'NRkAqXy32zY6LuDA4go2FTF1Cy85jvEfSu6DPTevOmSu441+7WhVZocyqdhT1kNB'
59
59
  }
60
60
  }
61
61
  };
@@ -9,7 +9,7 @@ function track(payload) {
9
9
  }
10
10
  if (navigator.webdriver || 'Cypress' in window) {
11
11
  return false;
12
- }
12
+ }
13
13
 
14
14
  return navigator.sendBeacon(EVENT_URL, payload.buffer);
15
15
  }
@@ -35,7 +35,8 @@ function asUint32(x) {
35
35
  const encoder = new TextEncoder();
36
36
 
37
37
  let hasInitializedSession = false;
38
- export function trackSessionInit() {
38
+ /** @param {string} version */
39
+ export function trackSessionInit(version) {
39
40
  if (hasInitializedSession) {
40
41
  return true;
41
42
  }
@@ -43,10 +44,13 @@ export function trackSessionInit() {
43
44
  hasInitializedSession = true;
44
45
 
45
46
  const encodedHostname = encoder.encode(location.hostname);
47
+ const encodedVersion = encoder.encode(version);
46
48
  return track(concat(
47
49
  new Uint8Array([ 0x01 ]),
48
- new Uint8Array([ 0x90, 0x63, 0x8A, 0xE7 ]),
50
+ new Uint8Array([ 0x90, 0x61, 0x8A, 0xE7 ]),
49
51
  asUint32(encodedHostname.byteLength),
50
- encodedHostname
52
+ encodedHostname,
53
+ asUint32(encodedVersion.byteLength),
54
+ encodedVersion
51
55
  ));
52
56
  }
@@ -124,6 +124,21 @@ export class YoloPipeline {
124
124
  * Returns a JS error if the buffer size is not `width * height * 4`.
125
125
  */
126
126
  preprocess_rgba(rgba: Uint8Array, width: number, height: number): Float32Array;
127
+ /**
128
+ * Adopt the input shape the engine reports for the compiled model.
129
+ *
130
+ * Without it the size comes from the metadata, which the graph itself never has to
131
+ * agree with, and [`input_shape`](Self::input_shape) is what the caller sizes its
132
+ * input tensor from - so a stale `imgsz` would feed the model a tensor it rejects.
133
+ * The ONNX path reads the same fact off its session; this is the LiteRT equivalent,
134
+ * which only the JS engine can see.
135
+ *
136
+ * Expects NCHW `[N, 3, H, W]`, what `ai_edge_torch` emits, with the signed dimensions
137
+ * the engine reports. Any other rank or layout (a channels-last `[N, H, W, 3]`) and any
138
+ * non-positive axis, which is how a dynamic dimension is reported, is ignored and leaves
139
+ * the metadata size in place.
140
+ */
141
+ setInputShape(shape: Int32Array): void;
127
142
  /**
128
143
  * Whether this is an end-to-end (NMS-free) export, e.g. YOLO26. Its head runs
129
144
  * the NMS/top-k with `int64`/`gather_nd` ops that the LiteRT WebGPU delegate
@@ -182,12 +197,13 @@ export interface InitOutput {
182
197
  readonly yolopipeline_new: (a: number, b: number, c: number) => void;
183
198
  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;
184
199
  readonly yolopipeline_preprocess_rgba: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
200
+ readonly yolopipeline_setInputShape: (a: number, b: number, c: number) => void;
185
201
  readonly yolopipeline_task: (a: number, b: number) => void;
186
202
  readonly start: () => void;
187
- readonly __wasm_bindgen_func_elem_1941: (a: number, b: number, c: number, d: number) => void;
188
- readonly __wasm_bindgen_func_elem_2540: (a: number, b: number, c: number, d: number) => void;
189
- readonly __wasm_bindgen_func_elem_1941_2: (a: number, b: number, c: number, d: number) => void;
190
- readonly __wasm_bindgen_func_elem_2564: (a: number, b: number, c: number, d: number) => void;
203
+ readonly __wasm_bindgen_func_elem_1956: (a: number, b: number, c: number, d: number) => void;
204
+ readonly __wasm_bindgen_func_elem_2558: (a: number, b: number, c: number, d: number) => void;
205
+ readonly __wasm_bindgen_func_elem_1956_2: (a: number, b: number, c: number, d: number) => void;
206
+ readonly __wasm_bindgen_func_elem_2582: (a: number, b: number, c: number, d: number) => void;
191
207
  readonly __wbindgen_export: (a: number, b: number) => number;
192
208
  readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
193
209
  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-c7b42e3e9fb58316/_loader.js';
3
- import { trackSessionInit } from './snippets/ort-web-c7b42e3e9fb58316/_telemetry.js';
2
+ import { initRuntime } from './snippets/ort-web-74be4d1a4544c8bc/_loader.js';
3
+ import { trackSessionInit } from './snippets/ort-web-74be4d1a4544c8bc/_telemetry.js';
4
4
 
5
5
 
6
6
  /**
@@ -369,6 +369,26 @@ export class YoloPipeline {
369
369
  wasm.__wbindgen_add_to_stack_pointer(16);
370
370
  }
371
371
  }
372
+ /**
373
+ * Adopt the input shape the engine reports for the compiled model.
374
+ *
375
+ * Without it the size comes from the metadata, which the graph itself never has to
376
+ * agree with, and [`input_shape`](Self::input_shape) is what the caller sizes its
377
+ * input tensor from - so a stale `imgsz` would feed the model a tensor it rejects.
378
+ * The ONNX path reads the same fact off its session; this is the LiteRT equivalent,
379
+ * which only the JS engine can see.
380
+ *
381
+ * Expects NCHW `[N, 3, H, W]`, what `ai_edge_torch` emits, with the signed dimensions
382
+ * the engine reports. Any other rank or layout (a channels-last `[N, H, W, 3]`) and any
383
+ * non-positive axis, which is how a dynamic dimension is reported, is ignored and leaves
384
+ * the metadata size in place.
385
+ * @param {Int32Array} shape
386
+ */
387
+ setInputShape(shape) {
388
+ const ptr0 = passArray32ToWasm0(shape, wasm.__wbindgen_export);
389
+ const len0 = WASM_VECTOR_LEN;
390
+ wasm.yolopipeline_setInputShape(this.__wbg_ptr, ptr0, len0);
391
+ }
372
392
  /**
373
393
  * The model's task (`"detect"`, `"segment"`, ...).
374
394
  * @returns {string}
@@ -527,19 +547,19 @@ function __wbg_get_imports() {
527
547
  const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
528
548
  return addHeapObject(ret);
529
549
  }, arguments); },
530
- __wbg_create_604d3dd8b0220101: function() { return handleError(function (arg0, arg1, arg2) {
550
+ __wbg_create_8f5a33c6bfe341e8: function() { return handleError(function (arg0, arg1, arg2) {
531
551
  const ret = ort.InferenceSession.create(getStringFromWasm0(arg0, arg1), takeObject(arg2));
532
552
  return addHeapObject(ret);
533
553
  }, arguments); },
534
- __wbg_create_aa26088c323fe759: function() { return handleError(function (arg0, arg1) {
554
+ __wbg_create_ab62f00735deac66: function() { return handleError(function (arg0, arg1) {
535
555
  const ret = ort.InferenceSession.create(getObject(arg0), takeObject(arg1));
536
556
  return addHeapObject(ret);
537
557
  }, arguments); },
538
- __wbg_data_f77ae23e62caa57c: function() { return handleError(function (arg0) {
558
+ __wbg_data_926466624da78512: function() { return handleError(function (arg0) {
539
559
  const ret = getObject(arg0).data;
540
560
  return addHeapObject(ret);
541
561
  }, arguments); },
542
- __wbg_dims_4cbc39371d1db46c: function(arg0, arg1) {
562
+ __wbg_dims_9f13b995a90df835: function(arg0, arg1) {
543
563
  const ret = getObject(arg1).dims;
544
564
  const ptr1 = passArray32ToWasm0(ret, wasm.__wbindgen_export);
545
565
  const len1 = WASM_VECTOR_LEN;
@@ -569,7 +589,7 @@ function __wbg_get_imports() {
569
589
  const ret = Array.from(getObject(arg0));
570
590
  return addHeapObject(ret);
571
591
  },
572
- __wbg_getData_87474928ad362e4c: function() { return handleError(function (arg0) {
592
+ __wbg_getData_1b8044301ffc7d79: function() { return handleError(function (arg0) {
573
593
  const ret = getObject(arg0).getData();
574
594
  return addHeapObject(ret);
575
595
  }, arguments); },
@@ -593,18 +613,18 @@ function __wbg_get_imports() {
593
613
  const ret = getObject(arg0)[getObject(arg1)];
594
614
  return addHeapObject(ret);
595
615
  },
596
- __wbg_initRuntime_8e839bc51a59b99d: function() { return handleError(function (arg0, arg1) {
616
+ __wbg_initRuntime_461bceccb341c20d: function() { return handleError(function (arg0, arg1) {
597
617
  const ret = initRuntime(arg0, takeObject(arg1));
598
618
  return addHeapObject(ret);
599
619
  }, arguments); },
600
- __wbg_inputMetadata_87b8670ec1aecff3: function(arg0, arg1) {
620
+ __wbg_inputMetadata_5ab975ce7a9db793: function(arg0, arg1) {
601
621
  const ret = getObject(arg1).inputMetadata;
602
622
  const ptr1 = passArrayJsValueToWasm0(ret, wasm.__wbindgen_export);
603
623
  const len1 = WASM_VECTOR_LEN;
604
624
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
605
625
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
606
626
  },
607
- __wbg_inputNames_006e79de2e9d06b0: function(arg0, arg1) {
627
+ __wbg_inputNames_379bb0f6b0bbddb0: function(arg0, arg1) {
608
628
  const ret = getObject(arg1).inputNames;
609
629
  const ptr1 = passArrayJsValueToWasm0(ret, wasm.__wbindgen_export);
610
630
  const len1 = WASM_VECTOR_LEN;
@@ -675,7 +695,7 @@ function __wbg_get_imports() {
675
695
  const ret = getObject(arg0).length;
676
696
  return ret;
677
697
  },
678
- __wbg_location_40d7e9906760d235: function(arg0) {
698
+ __wbg_location_b0c2e70b6a815475: function(arg0) {
679
699
  const ret = getObject(arg0).location;
680
700
  return (__wbindgen_enum_DataLocation.indexOf(ret) + 1 || 7) - 1;
681
701
  },
@@ -699,7 +719,7 @@ function __wbg_get_imports() {
699
719
  const ret = new Object();
700
720
  return addHeapObject(ret);
701
721
  },
702
- __wbg_new_from_buffer_raw_4a1de2fd5040de11: function() { return handleError(function (arg0, arg1, arg2) {
722
+ __wbg_new_from_buffer_raw_913772a28563e085: function() { return handleError(function (arg0, arg1, arg2) {
703
723
  const ret = new ort.Tensor(__wbindgen_enum_DataType[arg0], takeObject(arg1), takeObject(arg2));
704
724
  return addHeapObject(ret);
705
725
  }, arguments); },
@@ -714,7 +734,7 @@ function __wbg_get_imports() {
714
734
  const a = state0.a;
715
735
  state0.a = 0;
716
736
  try {
717
- return __wasm_bindgen_func_elem_2564(a, state0.b, arg0, arg1);
737
+ return __wasm_bindgen_func_elem_2582(a, state0.b, arg0, arg1);
718
738
  } finally {
719
739
  state0.a = a;
720
740
  }
@@ -781,14 +801,14 @@ function __wbg_get_imports() {
781
801
  const ret = getObject(arg0).now();
782
802
  return ret;
783
803
  },
784
- __wbg_outputMetadata_f60f543c30563643: function(arg0, arg1) {
804
+ __wbg_outputMetadata_7800f416aa5ef49d: function(arg0, arg1) {
785
805
  const ret = getObject(arg1).outputMetadata;
786
806
  const ptr1 = passArrayJsValueToWasm0(ret, wasm.__wbindgen_export);
787
807
  const len1 = WASM_VECTOR_LEN;
788
808
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
789
809
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
790
810
  },
791
- __wbg_outputNames_5e88e61bf53e5de8: function(arg0, arg1) {
811
+ __wbg_outputNames_e4fd207c684625a6: function(arg0, arg1) {
792
812
  const ret = getObject(arg1).outputNames;
793
813
  const ptr1 = passArrayJsValueToWasm0(ret, wasm.__wbindgen_export);
794
814
  const len1 = WASM_VECTOR_LEN;
@@ -824,7 +844,7 @@ function __wbg_get_imports() {
824
844
  const ret = Promise.resolve(getObject(arg0));
825
845
  return addHeapObject(ret);
826
846
  },
827
- __wbg_run_91f1b7e43bde55af: function() { return handleError(function (arg0, arg1) {
847
+ __wbg_run_00a506dcbf8e4bb0: function() { return handleError(function (arg0, arg1) {
828
848
  const ret = getObject(arg0).run(takeObject(arg1));
829
849
  return addHeapObject(ret);
830
850
  }, arguments); },
@@ -887,11 +907,11 @@ function __wbg_get_imports() {
887
907
  const ret = getObject(arg0).toString();
888
908
  return addHeapObject(ret);
889
909
  },
890
- __wbg_trackSessionInit_d2f5559748b8ff80: function() { return handleError(function () {
891
- const ret = trackSessionInit();
910
+ __wbg_trackSessionInit_a492d3a59889a1ae: function() { return handleError(function (arg0, arg1) {
911
+ const ret = trackSessionInit(getStringFromWasm0(arg0, arg1));
892
912
  return addHeapObject(ret);
893
913
  }, arguments); },
894
- __wbg_type_5bf9facd6ac793eb: function(arg0) {
914
+ __wbg_type_36ea46c1a40b10d2: function(arg0) {
895
915
  const ret = getObject(arg0).type;
896
916
  return (__wbindgen_enum_DataType.indexOf(ret) + 1 || 16) - 1;
897
917
  },
@@ -904,18 +924,18 @@ function __wbg_get_imports() {
904
924
  return addHeapObject(ret);
905
925
  },
906
926
  __wbindgen_cast_0000000000000001: function(arg0, arg1) {
907
- // 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`.
908
- const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_1941);
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_1956);
909
929
  return addHeapObject(ret);
910
930
  },
911
931
  __wbindgen_cast_0000000000000002: function(arg0, arg1) {
912
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 910, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
913
- const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_2540);
932
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 914, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
933
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_2558);
914
934
  return addHeapObject(ret);
915
935
  },
916
936
  __wbindgen_cast_0000000000000003: function(arg0, arg1) {
917
- // 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`.
918
- const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_1941_2);
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_1956_2);
919
939
  return addHeapObject(ret);
920
940
  },
921
941
  __wbindgen_cast_0000000000000004: function(arg0) {
@@ -1002,10 +1022,10 @@ function __wbg_get_imports() {
1002
1022
  };
1003
1023
  }
1004
1024
 
1005
- function __wasm_bindgen_func_elem_1941(arg0, arg1, arg2) {
1025
+ function __wasm_bindgen_func_elem_1956(arg0, arg1, arg2) {
1006
1026
  try {
1007
1027
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1008
- wasm.__wasm_bindgen_func_elem_1941(retptr, arg0, arg1, addHeapObject(arg2));
1028
+ wasm.__wasm_bindgen_func_elem_1956(retptr, arg0, arg1, addHeapObject(arg2));
1009
1029
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1010
1030
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1011
1031
  if (r1) {
@@ -1016,10 +1036,10 @@ function __wasm_bindgen_func_elem_1941(arg0, arg1, arg2) {
1016
1036
  }
1017
1037
  }
1018
1038
 
1019
- function __wasm_bindgen_func_elem_2540(arg0, arg1, arg2) {
1039
+ function __wasm_bindgen_func_elem_2558(arg0, arg1, arg2) {
1020
1040
  try {
1021
1041
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1022
- wasm.__wasm_bindgen_func_elem_2540(retptr, arg0, arg1, addHeapObject(arg2));
1042
+ wasm.__wasm_bindgen_func_elem_2558(retptr, arg0, arg1, addHeapObject(arg2));
1023
1043
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1024
1044
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1025
1045
  if (r1) {
@@ -1030,10 +1050,10 @@ function __wasm_bindgen_func_elem_2540(arg0, arg1, arg2) {
1030
1050
  }
1031
1051
  }
1032
1052
 
1033
- function __wasm_bindgen_func_elem_1941_2(arg0, arg1, arg2) {
1053
+ function __wasm_bindgen_func_elem_1956_2(arg0, arg1, arg2) {
1034
1054
  try {
1035
1055
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1036
- wasm.__wasm_bindgen_func_elem_1941_2(retptr, arg0, arg1, addHeapObject(arg2));
1056
+ wasm.__wasm_bindgen_func_elem_1956_2(retptr, arg0, arg1, addHeapObject(arg2));
1037
1057
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1038
1058
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1039
1059
  if (r1) {
@@ -1044,8 +1064,8 @@ function __wasm_bindgen_func_elem_1941_2(arg0, arg1, arg2) {
1044
1064
  }
1045
1065
  }
1046
1066
 
1047
- function __wasm_bindgen_func_elem_2564(arg0, arg1, arg2, arg3) {
1048
- wasm.__wasm_bindgen_func_elem_2564(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
1067
+ function __wasm_bindgen_func_elem_2582(arg0, arg1, arg2, arg3) {
1068
+ wasm.__wasm_bindgen_func_elem_2582(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
1049
1069
  }
1050
1070
 
1051
1071
 
@@ -16,12 +16,13 @@ export const yolopipeline_names: (a: number, b: number) => void;
16
16
  export const yolopipeline_new: (a: number, b: number, c: number) => void;
17
17
  export const yolopipeline_postprocess: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number) => void;
18
18
  export const yolopipeline_preprocess_rgba: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
19
+ export const yolopipeline_setInputShape: (a: number, b: number, c: number) => void;
19
20
  export const yolopipeline_task: (a: number, b: number) => void;
20
21
  export const start: () => void;
21
- export const __wasm_bindgen_func_elem_1941: (a: number, b: number, c: number, d: number) => void;
22
- export const __wasm_bindgen_func_elem_2540: (a: number, b: number, c: number, d: number) => void;
23
- export const __wasm_bindgen_func_elem_1941_2: (a: number, b: number, c: number, d: number) => void;
24
- export const __wasm_bindgen_func_elem_2564: (a: number, b: number, c: number, d: number) => void;
22
+ export const __wasm_bindgen_func_elem_1956: (a: number, b: number, c: number, d: number) => void;
23
+ export const __wasm_bindgen_func_elem_2558: (a: number, b: number, c: number, d: number) => void;
24
+ export const __wasm_bindgen_func_elem_1956_2: (a: number, b: number, c: number, d: number) => void;
25
+ export const __wasm_bindgen_func_elem_2582: (a: number, b: number, c: number, d: number) => void;
25
26
  export const __wbindgen_export: (a: number, b: number) => number;
26
27
  export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
27
28
  export const __wbindgen_export3: (a: number) => void;