@ultralytics/yolo 0.0.23 → 0.0.25
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 +68 -5
- package/dist/index.d.ts +24 -9
- package/dist/index.js +263 -31
- package/package.json +10 -1
- package/pkg/package.json +1 -1
- package/pkg/ultralytics_inference_web.d.ts +94 -6
- package/pkg/ultralytics_inference_web.js +234 -17
- package/pkg/ultralytics_inference_web_bg.wasm +0 -0
- package/pkg/ultralytics_inference_web_bg.wasm.d.ts +12 -4
package/README.md
CHANGED
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
[](https://www.npmjs.com/package/@ultralytics/yolo)
|
|
8
8
|
[](https://www.npmjs.com/package/@ultralytics/yolo)
|
|
9
9
|
[](https://github.com/ultralytics/inference/actions/workflows/ci.yml)
|
|
10
|
-
[](https://github.com/ultralytics/inference/blob/main/LICENSE)
|
|
11
|
+
[](https://arxiv.org/abs/2606.03748)
|
|
11
12
|
|
|
12
13
|
[](https://discord.com/invite/ultralytics)
|
|
13
14
|
[](https://community.ultralytics.com/)
|
|
@@ -135,7 +136,7 @@ Field names match the Rust/Ultralytics `Results` API 1-1:
|
|
|
135
136
|
| `keypoints` | `{ points: [x, y, conf][], color }[]` | pose |
|
|
136
137
|
| `probs` | `{ top1, top5, top1conf, top5conf, name, color } \| null` | classify |
|
|
137
138
|
| `masks` | `Uint8Array` (RGBA overlay, `width*height*4`) | segment, semantic |
|
|
138
|
-
| `
|
|
139
|
+
| `semantic_mask` | `Uint16Array` (class id per pixel, `width*height`) | semantic |
|
|
139
140
|
| `speed` | `{ preprocess, inference, postprocess }` ms | all |
|
|
140
141
|
|
|
141
142
|
`model.names` is the class id to name map (like `model.names` in Python). Every
|
|
@@ -158,9 +159,14 @@ the native renderer. None of this is duplicated in JS.
|
|
|
158
159
|
```python
|
|
159
160
|
from ultralytics import YOLO
|
|
160
161
|
|
|
161
|
-
YOLO("yolo26n.pt").export(format="onnx")
|
|
162
|
+
YOLO("yolo26n.pt").export(format="onnx") # FP32 (default)
|
|
163
|
+
YOLO("yolo26n.pt").export(format="onnx", quantize=16) # FP16 (~50% smaller)
|
|
162
164
|
```
|
|
163
165
|
|
|
166
|
+
> Ultralytics ≥8.4 uses the `quantize` argument instead of the deprecated
|
|
167
|
+
> `half=True` / `int8=True` flags. For ONNX the supported values are
|
|
168
|
+
> `32`/`fp32` (default), `16`/`fp16`, and `8`/`int8`.
|
|
169
|
+
|
|
164
170
|
- **Runtime assets**: on first load, `ort-web` fetches the ONNX Runtime Web wasm
|
|
165
171
|
bundle (~25 MB, browser-cached afterward) from `cdn.pyke.io`. If you set a
|
|
166
172
|
Content-Security-Policy, allow that origin in `script-src`/`connect-src`. To
|
|
@@ -175,6 +181,63 @@ the native renderer. None of this is duplicated in JS.
|
|
|
175
181
|
creation. See the [ort-web docs](https://ort.pyke.io/backends/web) to review or
|
|
176
182
|
disable it.
|
|
177
183
|
|
|
184
|
+
## ⚡ LiteRT.js backend
|
|
185
|
+
|
|
186
|
+
An alternative inference engine that runs an Ultralytics **`.tflite`** export
|
|
187
|
+
through [**LiteRT.js**](https://developers.google.com/edge/litert/web) (Google's
|
|
188
|
+
LiteRT for Web), which is often **~2× faster than ONNX Runtime Web on WebGPU**.
|
|
189
|
+
Only the inference engine changes; the preprocessing, postprocessing, drawing,
|
|
190
|
+
and `Results` shape are the same shared Rust code, so output matches the `ort`
|
|
191
|
+
path.
|
|
192
|
+
|
|
193
|
+
It is picked automatically from the file extension: pass a `.tflite` to
|
|
194
|
+
`YOLO.load` and it runs on LiteRT.js (a `.onnx` runs on ONNX Runtime Web). The
|
|
195
|
+
only setup is the optional peer dependency.
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
npm install @litertjs/core # optional peer dependency, only for .tflite models
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
```ts
|
|
202
|
+
import { YOLO, annotate } from "@ultralytics/yolo";
|
|
203
|
+
|
|
204
|
+
const model = await YOLO.load("/models/yolo26n.tflite", {
|
|
205
|
+
// LiteRT.js wasm assets; defaults to the jsDelivr CDN. Self-host by copying
|
|
206
|
+
// node_modules/@litertjs/core/wasm/ and pointing here (URL ending in `/`).
|
|
207
|
+
litertWasmUrl: "/litert/",
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
const results = await model.predict(video); // same API, same Results
|
|
211
|
+
console.log(model.device); // "webgpu" or "wasm"
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
Notes:
|
|
215
|
+
|
|
216
|
+
- **Model**: export with Ultralytics to `.tflite` (float32 for WebGPU). It loads
|
|
217
|
+
from the single file. The metadata (task, class names, `imgsz`, stride) is read
|
|
218
|
+
straight from the `.tflite`, the same as the `.onnx` path. No sidecar.
|
|
219
|
+
- **Requires Ultralytics `>= 8.4.83`**: the single-file LiteRT export (with
|
|
220
|
+
embedded metadata) ships in
|
|
221
|
+
[v8.4.83](https://github.com/ultralytics/ultralytics/releases/tag/v8.4.83) and
|
|
222
|
+
later. Earlier versions emit the legacy TFLite format and won't load here.
|
|
223
|
+
- **Export end2end-free models** (`end2end=False`): YOLO26 (and YOLOv10) default
|
|
224
|
+
to an end-to-end, NMS-free head whose `int64` / `gather_nd` ops the LiteRT
|
|
225
|
+
**WebGPU** delegate cannot run, so those exports silently fall back to CPU/wasm.
|
|
226
|
+
Export them with `end2end=False` so the standard head is used and NMS runs in
|
|
227
|
+
this package's Rust, keeping inference on WebGPU:
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
yolo export model=yolo26n.pt format=litert end2end=False
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
If you load an end2end `.tflite` anyway, the backend auto-switches it to wasm
|
|
234
|
+
(slower) and logs a warning rather than returning empty results.
|
|
235
|
+
|
|
236
|
+
- **Tasks**: detect, segment, pose, obb, classify, and semantic are all supported.
|
|
237
|
+
- **Cross-origin isolation**: LiteRT's threaded wasm wants `SharedArrayBuffer`,
|
|
238
|
+
so serve with `Cross-Origin-Opener-Policy: same-origin` and
|
|
239
|
+
`Cross-Origin-Embedder-Policy: require-corp`.
|
|
240
|
+
|
|
178
241
|
## 🔨 Building From Source
|
|
179
242
|
|
|
180
243
|
This package builds the wasm from the Rust crate with
|
|
@@ -184,8 +247,8 @@ This package builds the wasm from the Rust crate with
|
|
|
184
247
|
npm run build # wasm-pack build + tsc
|
|
185
248
|
```
|
|
186
249
|
|
|
187
|
-
Serve the built
|
|
188
|
-
in a WebGPU browser.
|
|
250
|
+
Serve the built package over `localhost` (a secure context) with the two
|
|
251
|
+
cross-origin isolation headers above, then open it in a WebGPU browser.
|
|
189
252
|
|
|
190
253
|
## 💡 Contributing
|
|
191
254
|
|
package/dist/index.d.ts
CHANGED
|
@@ -33,6 +33,8 @@ export interface Probs {
|
|
|
33
33
|
top1conf: number;
|
|
34
34
|
top5conf: number[];
|
|
35
35
|
name: string;
|
|
36
|
+
/** Display names for each {@link top5} class. */
|
|
37
|
+
top5names: string[];
|
|
36
38
|
color: string;
|
|
37
39
|
}
|
|
38
40
|
/** Per-stage timing in ms. */
|
|
@@ -57,7 +59,7 @@ export interface Results {
|
|
|
57
59
|
* `undefined` for other tasks. The sentinel `65535` marks background or
|
|
58
60
|
* class-filtered pixels. The `masks` overlay is its renderable form.
|
|
59
61
|
*/
|
|
60
|
-
|
|
62
|
+
semantic_mask?: Uint16Array;
|
|
61
63
|
speed: Speed;
|
|
62
64
|
}
|
|
63
65
|
/** Options for {@link YOLO.load}. */
|
|
@@ -82,6 +84,13 @@ export interface LoadOptions {
|
|
|
82
84
|
* falls back to CPU; read {@link YOLO.device} to see what actually ran.
|
|
83
85
|
*/
|
|
84
86
|
device?: "auto" | "webgpu" | "cpu";
|
|
87
|
+
/**
|
|
88
|
+
* Base URL of the `@litertjs/core` wasm assets folder, used when the model is a
|
|
89
|
+
* `.tflite` (run through LiteRT.js). Defaults to the jsDelivr CDN. Self-host by
|
|
90
|
+
* copying `node_modules/@litertjs/core/wasm/` and pointing here (absolute URL
|
|
91
|
+
* ending in `/`). Requires the optional `@litertjs/core` peer dependency.
|
|
92
|
+
*/
|
|
93
|
+
litertWasmUrl?: string | URL;
|
|
85
94
|
}
|
|
86
95
|
/** Options for {@link YOLO.predict}. */
|
|
87
96
|
export interface PredictOptions {
|
|
@@ -115,18 +124,24 @@ export type ImageInput = string | URL | Blob | ArrayBuffer | Uint8Array | ImageD
|
|
|
115
124
|
* of a constructor.
|
|
116
125
|
*/
|
|
117
126
|
export declare class YOLO {
|
|
118
|
-
private readonly
|
|
127
|
+
private readonly engine;
|
|
119
128
|
private constructor();
|
|
120
129
|
/**
|
|
121
|
-
* Load a model and initialize the
|
|
130
|
+
* Load a model and initialize the inference backend.
|
|
131
|
+
*
|
|
132
|
+
* The engine is chosen from the model: a `.tflite` runs on LiteRT.js, an
|
|
133
|
+
* `.onnx` on ONNX Runtime Web.
|
|
122
134
|
*
|
|
123
|
-
* @param source
|
|
124
|
-
* @param options
|
|
135
|
+
* @param source Model URL/path, or its raw bytes (`.onnx` or `.tflite`).
|
|
136
|
+
* @param options Loader options.
|
|
125
137
|
*/
|
|
126
138
|
static load(source: string | URL | ArrayBuffer | Uint8Array, options?: LoadOptions): Promise<YOLO>;
|
|
139
|
+
/** Load the LiteRT (`.tflite`) backend. Metadata (task, class names, `imgsz`)
|
|
140
|
+
* is read from the single `.tflite` file, the same as the `.onnx` path. */
|
|
141
|
+
private static loadLiteRt;
|
|
127
142
|
/** The model's task (`detect`, `segment`, `pose`, `classify`, `obb`, `semantic`). */
|
|
128
143
|
get task(): string;
|
|
129
|
-
/** The active device that ran inference (`"webgpu"` or `"cpu"`). */
|
|
144
|
+
/** The active device that ran inference (`"webgpu"`, `"wasm"`, or `"cpu"`). */
|
|
130
145
|
get device(): string;
|
|
131
146
|
/** Class id -> name map (like Ultralytics `model.names`). */
|
|
132
147
|
get names(): Record<number, string>;
|
|
@@ -136,20 +151,20 @@ export declare class YOLO {
|
|
|
136
151
|
* Drawable sources (`ImageData`, `HTMLImageElement`, `HTMLCanvasElement`,
|
|
137
152
|
* `HTMLVideoElement`, `ImageBitmap`) take a fast path that reads raw pixels
|
|
138
153
|
* with no re-encoding, ideal for webcam/video. URLs, `Blob`s, and raw bytes
|
|
139
|
-
* are decoded
|
|
154
|
+
* are decoded (in wasm for `ort`, via a canvas for `litert`).
|
|
140
155
|
*
|
|
141
156
|
* @param image The image to run on.
|
|
142
157
|
* @param options Confidence/IoU thresholds.
|
|
143
158
|
*/
|
|
144
159
|
predict(image: ImageInput, options?: PredictOptions): Promise<Results>;
|
|
145
|
-
/** Release the underlying wasm model. Call when you are done with it. */
|
|
160
|
+
/** Release the underlying wasm model/engine. Call when you are done with it. */
|
|
146
161
|
free(): void;
|
|
147
162
|
}
|
|
148
163
|
/**
|
|
149
164
|
* Draw inference results onto a canvas, on top of the source image.
|
|
150
165
|
*
|
|
151
166
|
* Handles every task: axis-aligned boxes, oriented boxes (OBB), pose keypoints
|
|
152
|
-
* with the COCO skeleton, and a top-
|
|
167
|
+
* with the COCO skeleton, and a top-5 list for classification. The canvas is
|
|
153
168
|
* resized to the original image dimensions so detection coordinates line up.
|
|
154
169
|
*
|
|
155
170
|
* ```ts
|
package/dist/index.js
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* }
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
|
-
import init, { YoloModel, start, pose_palette } from "../pkg/ultralytics_inference_web.js";
|
|
20
|
+
import init, { YoloModel, YoloPipeline, start, pose_palette } from "../pkg/ultralytics_inference_web.js";
|
|
21
21
|
let poseSchemeCache = null;
|
|
22
22
|
/** The Ultralytics pose skeleton + per-keypoint/limb colors (constant). */
|
|
23
23
|
function poseScheme() {
|
|
@@ -55,14 +55,34 @@ const DEFAULT_KEYPOINT_THRESHOLD = 0.25;
|
|
|
55
55
|
function resolveModel(src) {
|
|
56
56
|
return /^[\w.-]+\.onnx$/i.test(src) ? ASSETS + src : src;
|
|
57
57
|
}
|
|
58
|
+
/** Whether `bytes` begin with a TFLite flatbuffer (the `TFL3` identifier at offset 4). */
|
|
59
|
+
function isTflite(bytes) {
|
|
60
|
+
return bytes.length >= 8 && bytes[4] === 0x54 && bytes[5] === 0x46 && bytes[6] === 0x4c && bytes[7] === 0x33;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Pick the inference backend from the model: `.tflite` -> `litert`, `.onnx` ->
|
|
64
|
+
* `ort`. When the source has no known extension (raw bytes, extensionless or
|
|
65
|
+
* signed URL), the already-fetched `bytes` are sniffed for the `TFL3` identifier.
|
|
66
|
+
*/
|
|
67
|
+
function inferBackend(source, bytes) {
|
|
68
|
+
if (typeof source === "string" || source instanceof URL) {
|
|
69
|
+
// Match on the pathname only so `model.tflite?v=1` or a signed URL still works.
|
|
70
|
+
const path = (source instanceof URL ? source.pathname : source).split(/[?#]/, 1)[0];
|
|
71
|
+
if (/\.tflite$/i.test(path))
|
|
72
|
+
return "litert";
|
|
73
|
+
if (/\.onnx$/i.test(path))
|
|
74
|
+
return "ort";
|
|
75
|
+
}
|
|
76
|
+
return isTflite(bytes) ? "litert" : "ort";
|
|
77
|
+
}
|
|
58
78
|
/**
|
|
59
|
-
* Reinterpret the wasm payload's little-endian `
|
|
79
|
+
* Reinterpret the wasm payload's little-endian `semantic_mask` bytes as a
|
|
60
80
|
* `Uint16Array` of class ids (a zero-copy view), leaving every other field as-is.
|
|
61
81
|
*/
|
|
62
82
|
function decodeResults(raw) {
|
|
63
83
|
const r = raw;
|
|
64
|
-
const sem = r.
|
|
65
|
-
r.
|
|
84
|
+
const sem = r.semantic_mask;
|
|
85
|
+
r.semantic_mask = sem && sem.length ? new Uint16Array(sem.buffer, sem.byteOffset, sem.length / 2) : undefined;
|
|
66
86
|
return r;
|
|
67
87
|
}
|
|
68
88
|
let initialized = false;
|
|
@@ -136,46 +156,248 @@ function get2d(canvas, options) {
|
|
|
136
156
|
throw new Error("could not acquire a 2D canvas context");
|
|
137
157
|
return ctx;
|
|
138
158
|
}
|
|
159
|
+
/** Default CDN for the LiteRT.js wasm assets (override via `litertWasmUrl`). */
|
|
160
|
+
const DEFAULT_LITERT_WASM = "https://cdn.jsdelivr.net/npm/@litertjs/core/wasm/";
|
|
161
|
+
/** Import the optional `@litertjs/core` peer dep. An indirect specifier keeps it
|
|
162
|
+
* out of the build graph, so the package never hard-depends on it. */
|
|
163
|
+
async function importLiteRt() {
|
|
164
|
+
const pkg = "@litertjs/core";
|
|
165
|
+
try {
|
|
166
|
+
return (await import(/* @vite-ignore */ pkg));
|
|
167
|
+
}
|
|
168
|
+
catch (e) {
|
|
169
|
+
// Keep the original error visible so a real load failure is not mistaken for
|
|
170
|
+
// a missing install.
|
|
171
|
+
throw new Error(`failed to load the optional peer dependency "@litertjs/core" for the .tflite backend (run \`npm install @litertjs/core\`): ${e}`);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
// LiteRT.js initializes its wasm runtime once per page; calling `loadLiteRt`
|
|
175
|
+
// again throws "LiteRT is already loading / loaded". Cache the first init so
|
|
176
|
+
// loading a second model (e.g. switching models in a demo) reuses it. The init
|
|
177
|
+
// is process-global, so a later load asking for a different `wasmUrl` is rejected
|
|
178
|
+
// (reload to switch) rather than silently reusing the original assets.
|
|
179
|
+
let litertInit = null;
|
|
180
|
+
let litertInitUrl = null;
|
|
181
|
+
function ensureLiteRtRuntime(litert, wasmUrl) {
|
|
182
|
+
if (litertInit) {
|
|
183
|
+
if (litertInitUrl !== wasmUrl) {
|
|
184
|
+
return Promise.reject(new Error(`LiteRT.js wasm is initialized once per page and shared by every model: already loaded from "${litertInitUrl}", cannot switch to "${wasmUrl}". Use the same litertWasmUrl, or reload the page.`));
|
|
185
|
+
}
|
|
186
|
+
return litertInit;
|
|
187
|
+
}
|
|
188
|
+
litertInitUrl = wasmUrl;
|
|
189
|
+
litertInit = litert.loadLiteRt(wasmUrl).catch((e) => {
|
|
190
|
+
litertInit = null; // let a later load retry if the first init failed
|
|
191
|
+
litertInitUrl = null;
|
|
192
|
+
throw e;
|
|
193
|
+
});
|
|
194
|
+
return litertInit;
|
|
195
|
+
}
|
|
196
|
+
/** Runs a `.tflite` model with LiteRT.js; inference only, pre/post stay in Rust. */
|
|
197
|
+
class LiteRtBackend {
|
|
198
|
+
constructor(litert, model, device) {
|
|
199
|
+
this.litert = litert;
|
|
200
|
+
this.model = model;
|
|
201
|
+
this.device = device;
|
|
202
|
+
}
|
|
203
|
+
/** Import LiteRT.js, init its wasm, and compile the model, falling back from
|
|
204
|
+
* WebGPU to wasm (CPU) if the GPU accelerator cannot compile. */
|
|
205
|
+
static async load(tflite, wasmUrl, accelerator) {
|
|
206
|
+
const litert = await importLiteRt();
|
|
207
|
+
await ensureLiteRtRuntime(litert, wasmUrl);
|
|
208
|
+
try {
|
|
209
|
+
const model = await litert.loadAndCompile(tflite, { accelerator });
|
|
210
|
+
return new LiteRtBackend(litert, model, accelerator);
|
|
211
|
+
}
|
|
212
|
+
catch (e) {
|
|
213
|
+
if (accelerator === "wasm")
|
|
214
|
+
throw e;
|
|
215
|
+
const model = await litert.loadAndCompile(tflite, { accelerator: "wasm" });
|
|
216
|
+
return new LiteRtBackend(litert, model, "wasm");
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
/** Upload the input tensor, run, and read every output back to the CPU. */
|
|
220
|
+
async run(input, shape) {
|
|
221
|
+
const t0 = performance.now();
|
|
222
|
+
const cpuIn = new this.litert.Tensor(input, shape);
|
|
223
|
+
let gpuIn;
|
|
224
|
+
try {
|
|
225
|
+
gpuIn = this.device === "wasm" ? cpuIn : await cpuIn.moveTo("webgpu");
|
|
226
|
+
const tensors = await this.model.run(gpuIn);
|
|
227
|
+
const outputs = [];
|
|
228
|
+
const shapes = [];
|
|
229
|
+
for (const t of tensors) {
|
|
230
|
+
const host = await t.moveTo("wasm");
|
|
231
|
+
// Copy out before deleting; toTypedArray() may view the freed buffer.
|
|
232
|
+
outputs.push(new Float32Array(host.toTypedArray()));
|
|
233
|
+
shapes.push(Array.from(host.type.layout.dimensions));
|
|
234
|
+
host.delete?.();
|
|
235
|
+
// moveTo("wasm") returns the same tensor when it is already on wasm; only
|
|
236
|
+
// delete the original separately when it is a distinct GPU tensor.
|
|
237
|
+
if (t !== host)
|
|
238
|
+
t.delete?.();
|
|
239
|
+
}
|
|
240
|
+
return { outputs, shapes, inferenceMs: performance.now() - t0 };
|
|
241
|
+
}
|
|
242
|
+
finally {
|
|
243
|
+
// Free the input tensors on both success and failure (per-frame loops leak fast).
|
|
244
|
+
if (gpuIn && gpuIn !== cpuIn)
|
|
245
|
+
gpuIn.delete?.();
|
|
246
|
+
cpuIn.delete?.();
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
free() {
|
|
250
|
+
this.model.delete?.();
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
/** ONNX Runtime Web engine: the full pipeline runs inside wasm. */
|
|
254
|
+
class OrtEngine {
|
|
255
|
+
constructor(model) {
|
|
256
|
+
this.model = model;
|
|
257
|
+
}
|
|
258
|
+
get task() {
|
|
259
|
+
return this.model.task;
|
|
260
|
+
}
|
|
261
|
+
get device() {
|
|
262
|
+
return this.model.device;
|
|
263
|
+
}
|
|
264
|
+
get names() {
|
|
265
|
+
return this.model.names;
|
|
266
|
+
}
|
|
267
|
+
predictDrawable(data, width, height, conf, iou, classes) {
|
|
268
|
+
return this.model.predict_rgba(data, width, height, conf, iou, classes);
|
|
269
|
+
}
|
|
270
|
+
predictEncoded(bytes, conf, iou, classes) {
|
|
271
|
+
return this.model.predict(bytes, conf, iou, classes);
|
|
272
|
+
}
|
|
273
|
+
free() {
|
|
274
|
+
this.model.free();
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
/** LiteRT.js engine: Rust preprocess → LiteRT inference → Rust postprocess. */
|
|
278
|
+
class LiteRtEngine {
|
|
279
|
+
constructor(pipeline, backend) {
|
|
280
|
+
this.pipeline = pipeline;
|
|
281
|
+
this.backend = backend;
|
|
282
|
+
// `YoloPipeline` keeps exactly one pending frame in wasm state between
|
|
283
|
+
// `preprocess_rgba` and `postprocess`, so predictions must not interleave.
|
|
284
|
+
// Serialize them: a new call waits for the in-flight one to finish.
|
|
285
|
+
this.queue = Promise.resolve();
|
|
286
|
+
}
|
|
287
|
+
get task() {
|
|
288
|
+
return this.pipeline.task;
|
|
289
|
+
}
|
|
290
|
+
get device() {
|
|
291
|
+
// Report the CPU path as "cpu" (the package-wide label); the LiteRT backend
|
|
292
|
+
// tracks it internally as "wasm".
|
|
293
|
+
return this.backend.device === "wasm" ? "cpu" : this.backend.device;
|
|
294
|
+
}
|
|
295
|
+
get names() {
|
|
296
|
+
return this.pipeline.names;
|
|
297
|
+
}
|
|
298
|
+
predictDrawable(data, width, height, conf, iou, classes) {
|
|
299
|
+
return this.serialize(() => this.runDrawable(data, width, height, conf, iou, classes));
|
|
300
|
+
}
|
|
301
|
+
/** LiteRT takes raw pixels, so decode encoded inputs to RGBA in JS first. */
|
|
302
|
+
predictEncoded(bytes, conf, iou, classes) {
|
|
303
|
+
return this.serialize(async () => {
|
|
304
|
+
const bitmap = await createImageBitmap(new Blob([bytes]));
|
|
305
|
+
try {
|
|
306
|
+
const { data, width, height } = toImageData(bitmap);
|
|
307
|
+
return await this.runDrawable(data, width, height, conf, iou, classes);
|
|
308
|
+
}
|
|
309
|
+
finally {
|
|
310
|
+
bitmap.close();
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
async runDrawable(data, width, height, conf, iou, classes) {
|
|
315
|
+
const input = this.pipeline.preprocess_rgba(data, width, height);
|
|
316
|
+
const { outputs, shapes, inferenceMs } = await this.backend.run(input, Array.from(this.pipeline.inputShape));
|
|
317
|
+
// Flatten shapes as [rank, dims..., rank, dims...] for the wasm boundary.
|
|
318
|
+
const flatShapes = [];
|
|
319
|
+
for (const s of shapes)
|
|
320
|
+
flatShapes.push(s.length, ...s);
|
|
321
|
+
return this.pipeline.postprocess(outputs, new Uint32Array(flatShapes), inferenceMs, conf, iou, classes);
|
|
322
|
+
}
|
|
323
|
+
/** Chain `fn` after any in-flight prediction so wasm frame state is never shared. */
|
|
324
|
+
serialize(fn) {
|
|
325
|
+
const result = this.queue.then(fn, fn);
|
|
326
|
+
this.queue = result.then(() => undefined, () => undefined);
|
|
327
|
+
return result;
|
|
328
|
+
}
|
|
329
|
+
free() {
|
|
330
|
+
this.pipeline.free();
|
|
331
|
+
this.backend.free();
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
/** Fetch model bytes from a URL/path, or pass provided bytes through. */
|
|
335
|
+
async function fetchModelBytes(source) {
|
|
336
|
+
if (typeof source === "string" || source instanceof URL) {
|
|
337
|
+
const resp = await fetchOk(source.toString(), "model");
|
|
338
|
+
return new Uint8Array(await resp.arrayBuffer());
|
|
339
|
+
}
|
|
340
|
+
return source instanceof Uint8Array ? source : new Uint8Array(source);
|
|
341
|
+
}
|
|
139
342
|
/**
|
|
140
343
|
* A loaded YOLO model. Loading is asynchronous, so use {@link YOLO.load} instead
|
|
141
344
|
* of a constructor.
|
|
142
345
|
*/
|
|
143
346
|
export class YOLO {
|
|
144
|
-
constructor(
|
|
145
|
-
this.
|
|
347
|
+
constructor(engine) {
|
|
348
|
+
this.engine = engine;
|
|
146
349
|
}
|
|
147
350
|
/**
|
|
148
|
-
* Load a model and initialize the
|
|
351
|
+
* Load a model and initialize the inference backend.
|
|
149
352
|
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
353
|
+
* The engine is chosen from the model: a `.tflite` runs on LiteRT.js, an
|
|
354
|
+
* `.onnx` on ONNX Runtime Web.
|
|
355
|
+
*
|
|
356
|
+
* @param source Model URL/path, or its raw bytes (`.onnx` or `.tflite`).
|
|
357
|
+
* @param options Loader options.
|
|
152
358
|
*/
|
|
153
359
|
static async load(source, options) {
|
|
154
360
|
await ensureInit(options?.wasmUrl);
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
}
|
|
161
|
-
else {
|
|
162
|
-
bytes = source instanceof Uint8Array ? source : new Uint8Array(source);
|
|
361
|
+
// Fetch once (a bare `.onnx` name resolves to the Ultralytics assets release),
|
|
362
|
+
// then pick the backend from the extension, or the bytes when it is unknown.
|
|
363
|
+
const bytes = await fetchModelBytes(typeof source === "string" ? resolveModel(source) : source);
|
|
364
|
+
if (inferBackend(source, bytes) === "litert") {
|
|
365
|
+
return YOLO.loadLiteRt(bytes, options);
|
|
163
366
|
}
|
|
164
367
|
const ortBaseUrl = options?.ortBaseUrl ? options.ortBaseUrl.toString() : undefined;
|
|
165
368
|
const device = await resolveDevice(options?.device);
|
|
166
|
-
return new YOLO(await YoloModel.load_bytes(bytes, ortBaseUrl, device));
|
|
369
|
+
return new YOLO(new OrtEngine(await YoloModel.load_bytes(bytes, ortBaseUrl, device)));
|
|
370
|
+
}
|
|
371
|
+
/** Load the LiteRT (`.tflite`) backend. Metadata (task, class names, `imgsz`)
|
|
372
|
+
* is read from the single `.tflite` file, the same as the `.onnx` path. */
|
|
373
|
+
static async loadLiteRt(tflite, options) {
|
|
374
|
+
const pipeline = new YoloPipeline(tflite);
|
|
375
|
+
const wasmUrl = options?.litertWasmUrl ? options.litertWasmUrl.toString() : DEFAULT_LITERT_WASM;
|
|
376
|
+
// Honor `device` including `"auto"`, which feature-detects WebGPU (so a
|
|
377
|
+
// browser without it goes straight to wasm instead of a failed compile).
|
|
378
|
+
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
|
|
380
|
+
// LiteRT WebGPU delegate cannot run: it fails to invoke and returns zeros.
|
|
381
|
+
// 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.
|
|
383
|
+
if (accelerator === "webgpu" && pipeline.end2end) {
|
|
384
|
+
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.");
|
|
386
|
+
}
|
|
387
|
+
const backend = await LiteRtBackend.load(tflite, wasmUrl, accelerator);
|
|
388
|
+
return new YOLO(new LiteRtEngine(pipeline, backend));
|
|
167
389
|
}
|
|
168
390
|
/** The model's task (`detect`, `segment`, `pose`, `classify`, `obb`, `semantic`). */
|
|
169
391
|
get task() {
|
|
170
|
-
return this.
|
|
392
|
+
return this.engine.task;
|
|
171
393
|
}
|
|
172
|
-
/** The active device that ran inference (`"webgpu"` or `"cpu"`). */
|
|
394
|
+
/** The active device that ran inference (`"webgpu"`, `"wasm"`, or `"cpu"`). */
|
|
173
395
|
get device() {
|
|
174
|
-
return this.
|
|
396
|
+
return this.engine.device;
|
|
175
397
|
}
|
|
176
398
|
/** Class id -> name map (like Ultralytics `model.names`). */
|
|
177
399
|
get names() {
|
|
178
|
-
return this.
|
|
400
|
+
return this.engine.names;
|
|
179
401
|
}
|
|
180
402
|
/**
|
|
181
403
|
* Run inference on an image.
|
|
@@ -183,7 +405,7 @@ export class YOLO {
|
|
|
183
405
|
* Drawable sources (`ImageData`, `HTMLImageElement`, `HTMLCanvasElement`,
|
|
184
406
|
* `HTMLVideoElement`, `ImageBitmap`) take a fast path that reads raw pixels
|
|
185
407
|
* with no re-encoding, ideal for webcam/video. URLs, `Blob`s, and raw bytes
|
|
186
|
-
* are decoded
|
|
408
|
+
* are decoded (in wasm for `ort`, via a canvas for `litert`).
|
|
187
409
|
*
|
|
188
410
|
* @param image The image to run on.
|
|
189
411
|
* @param options Confidence/IoU thresholds.
|
|
@@ -194,14 +416,14 @@ export class YOLO {
|
|
|
194
416
|
const classes = options?.classes ? new Uint32Array(options.classes) : undefined;
|
|
195
417
|
if (isDrawable(image)) {
|
|
196
418
|
const { data, width, height } = toImageData(image);
|
|
197
|
-
return decodeResults(await this.
|
|
419
|
+
return decodeResults(await this.engine.predictDrawable(data, width, height, conf, iou, classes));
|
|
198
420
|
}
|
|
199
421
|
const bytes = await toEncodedBytes(image);
|
|
200
|
-
return decodeResults(await this.
|
|
422
|
+
return decodeResults(await this.engine.predictEncoded(bytes, conf, iou, classes));
|
|
201
423
|
}
|
|
202
|
-
/** Release the underlying wasm model. Call when you are done with it. */
|
|
424
|
+
/** Release the underlying wasm model/engine. Call when you are done with it. */
|
|
203
425
|
free() {
|
|
204
|
-
this.
|
|
426
|
+
this.engine.free();
|
|
205
427
|
}
|
|
206
428
|
}
|
|
207
429
|
// Colors come from the Rust engine (the Ultralytics palette) on each detection,
|
|
@@ -218,7 +440,7 @@ function textColorFor(hex) {
|
|
|
218
440
|
* Draw inference results onto a canvas, on top of the source image.
|
|
219
441
|
*
|
|
220
442
|
* Handles every task: axis-aligned boxes, oriented boxes (OBB), pose keypoints
|
|
221
|
-
* with the COCO skeleton, and a top-
|
|
443
|
+
* with the COCO skeleton, and a top-5 list for classification. The canvas is
|
|
222
444
|
* resized to the original image dimensions so detection coordinates line up.
|
|
223
445
|
*
|
|
224
446
|
* ```ts
|
|
@@ -324,9 +546,19 @@ export async function annotate(canvas, image, results, options) {
|
|
|
324
546
|
}
|
|
325
547
|
ctx.lineWidth = lineWidth;
|
|
326
548
|
}
|
|
327
|
-
// Classification: top-
|
|
328
|
-
|
|
329
|
-
|
|
549
|
+
// Classification: top-5 list on a translucent black panel (matches the native
|
|
550
|
+
// and Python renderers, which list the top classes rather than a single banner).
|
|
551
|
+
if (results.probs && showLabels) {
|
|
552
|
+
const { top5, top5conf, top5names } = results.probs;
|
|
553
|
+
const lines = top5.map((_, i) => `${top5names[i] ?? top5[i]} ${top5conf[i].toFixed(2)}`);
|
|
554
|
+
const pad = Math.round(fontSize * 0.3);
|
|
555
|
+
const lineH = Math.round(fontSize * 1.25);
|
|
556
|
+
const boxW = Math.max(...lines.map((t) => ctx.measureText(t).width)) + pad * 2;
|
|
557
|
+
const boxH = lines.length * lineH + pad * 2;
|
|
558
|
+
ctx.fillStyle = "rgba(0, 0, 0, 0.4)";
|
|
559
|
+
ctx.fillRect(pad, pad, boxW, boxH);
|
|
560
|
+
ctx.fillStyle = "#ffffff";
|
|
561
|
+
lines.forEach((t, i) => ctx.fillText(t, pad * 2, pad * 2 + i * lineH));
|
|
330
562
|
}
|
|
331
563
|
}
|
|
332
564
|
/** Resolve any {@link ImageInput} to something `drawImage` accepts. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultralytics/yolo",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.25",
|
|
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",
|
|
@@ -57,7 +57,16 @@
|
|
|
57
57
|
"url": "https://github.com/ultralytics/inference/issues"
|
|
58
58
|
},
|
|
59
59
|
"homepage": "https://www.ultralytics.com",
|
|
60
|
+
"peerDependencies": {
|
|
61
|
+
"@litertjs/core": "^2.5.0"
|
|
62
|
+
},
|
|
63
|
+
"peerDependenciesMeta": {
|
|
64
|
+
"@litertjs/core": {
|
|
65
|
+
"optional": true
|
|
66
|
+
}
|
|
67
|
+
},
|
|
60
68
|
"devDependencies": {
|
|
69
|
+
"@litertjs/core": "^2.5.0",
|
|
61
70
|
"typescript": "^5.4.0"
|
|
62
71
|
}
|
|
63
72
|
}
|
package/pkg/package.json
CHANGED
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* A loaded
|
|
5
|
+
* A loaded ONNX model that runs end to end in wasm (preprocess, inference on
|
|
6
|
+
* ONNX Runtime Web, and postprocess), for the `.onnx` path.
|
|
6
7
|
*
|
|
7
8
|
* Created via [`YoloModel::load_bytes`]; run with [`YoloModel::predict`]. The
|
|
8
|
-
* TypeScript
|
|
9
|
+
* TypeScript `YOLO` class wraps this for ONNX models, and [`YoloPipeline`] for
|
|
10
|
+
* `.tflite` ones.
|
|
9
11
|
*/
|
|
10
12
|
export class YoloModel {
|
|
11
13
|
private constructor();
|
|
@@ -69,6 +71,84 @@ export class YoloModel {
|
|
|
69
71
|
readonly task: string;
|
|
70
72
|
}
|
|
71
73
|
|
|
74
|
+
/**
|
|
75
|
+
* A metadata-only YOLO pre/post pipeline for use with an **external** inference
|
|
76
|
+
* engine (e.g. LiteRT.js running a `.tflite` model in JavaScript).
|
|
77
|
+
*
|
|
78
|
+
* Unlike [`YoloModel`], it holds no ONNX Runtime session: JavaScript loads and
|
|
79
|
+
* runs the model, while this struct reuses the shared Rust preprocessing and
|
|
80
|
+
* postprocessing so results match every other path. Per frame the flow is
|
|
81
|
+
* [`preprocess_rgba`](Self::preprocess_rgba) → (JS engine inference) →
|
|
82
|
+
* [`postprocess`](Self::postprocess). It assumes a single prediction in flight
|
|
83
|
+
* at a time (as the webcam render loop does).
|
|
84
|
+
*/
|
|
85
|
+
export class YoloPipeline {
|
|
86
|
+
free(): void;
|
|
87
|
+
[Symbol.dispose](): void;
|
|
88
|
+
/**
|
|
89
|
+
* Build a pipeline from a single-file `.tflite` model, reading the
|
|
90
|
+
* Ultralytics metadata (task, class names, `imgsz`, ...) embedded in the
|
|
91
|
+
* model bytes, the same way [`YoloModel::load_bytes`] reads it from an ONNX
|
|
92
|
+
* model, so the ONNX and LiteRT paths load identically from one file.
|
|
93
|
+
*
|
|
94
|
+
* # Errors
|
|
95
|
+
* Returns a JS error if the model carries no Ultralytics metadata or it
|
|
96
|
+
* cannot be parsed.
|
|
97
|
+
*/
|
|
98
|
+
constructor(tflite: Uint8Array);
|
|
99
|
+
/**
|
|
100
|
+
* Postprocess an external engine's raw outputs into the standard `Results`.
|
|
101
|
+
*
|
|
102
|
+
* `outputs` are the model's output tensors (one for most tasks; two for
|
|
103
|
+
* segmentation: detection head + mask prototypes). `shapes` encodes each
|
|
104
|
+
* output's dims flat as `[rank0, dims0..., rank1, dims1...]`. `inference_ms`
|
|
105
|
+
* is the time the JS engine reported, used only for the `speed` breakdown.
|
|
106
|
+
* Consumes the frame stashed by the preceding
|
|
107
|
+
* [`preprocess_rgba`](Self::preprocess_rgba).
|
|
108
|
+
*
|
|
109
|
+
* # Errors
|
|
110
|
+
* Returns a JS error if called before `preprocess_rgba`, if `shapes` is
|
|
111
|
+
* malformed, or on serialization failure.
|
|
112
|
+
*/
|
|
113
|
+
postprocess(outputs: Float32Array[], shapes: Uint32Array, inference_ms: number, conf: number, iou: number, classes?: Uint32Array | null): any;
|
|
114
|
+
/**
|
|
115
|
+
* Preprocess raw RGBA pixels (e.g. a webcam `ImageData`) into the NCHW f32
|
|
116
|
+
* input tensor an Ultralytics LiteRT/TFLite model expects, normalized to
|
|
117
|
+
* `[0, 1]`, the same preprocessing as the ONNX path.
|
|
118
|
+
*
|
|
119
|
+
* Returns the tensor as a `Float32Array` (shape `[1, 3, H, W]`); the
|
|
120
|
+
* letterbox geometry and original image are stashed for the matching
|
|
121
|
+
* [`postprocess`](Self::postprocess) call.
|
|
122
|
+
*
|
|
123
|
+
* # Errors
|
|
124
|
+
* Returns a JS error if the buffer size is not `width * height * 4`.
|
|
125
|
+
*/
|
|
126
|
+
preprocess_rgba(rgba: Uint8Array, width: number, height: number): Float32Array;
|
|
127
|
+
/**
|
|
128
|
+
* Whether this is an end-to-end (NMS-free) export, e.g. YOLO26. Its head runs
|
|
129
|
+
* the NMS/top-k with `int64`/`gather_nd` ops that the LiteRT WebGPU delegate
|
|
130
|
+
* cannot execute, so such models must run on the CPU (wasm) accelerator.
|
|
131
|
+
*/
|
|
132
|
+
readonly end2end: boolean;
|
|
133
|
+
/**
|
|
134
|
+
* The model input shape as `[1, 3, H, W]` (NCHW), for sizing the engine's
|
|
135
|
+
* input tensor. Ultralytics LiteRT exports (`ai_edge_torch`) keep the native
|
|
136
|
+
* NCHW layout, matching the ONNX path.
|
|
137
|
+
*/
|
|
138
|
+
readonly inputShape: Uint32Array;
|
|
139
|
+
/**
|
|
140
|
+
* Class id -> name map (like `model.names`), as a JS object.
|
|
141
|
+
*
|
|
142
|
+
* # Errors
|
|
143
|
+
* Returns a JS error only if serialization fails (not expected).
|
|
144
|
+
*/
|
|
145
|
+
readonly names: any;
|
|
146
|
+
/**
|
|
147
|
+
* The model's task (`"detect"`, `"segment"`, ...).
|
|
148
|
+
*/
|
|
149
|
+
readonly task: string;
|
|
150
|
+
}
|
|
151
|
+
|
|
72
152
|
/**
|
|
73
153
|
* Return the Ultralytics pose skeleton + keypoint/limb colors (constant). The
|
|
74
154
|
* JS annotator calls this once to color pose overlays from the shared palette.
|
|
@@ -88,6 +168,7 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
|
|
|
88
168
|
export interface InitOutput {
|
|
89
169
|
readonly memory: WebAssembly.Memory;
|
|
90
170
|
readonly __wbg_yolomodel_free: (a: number, b: number) => void;
|
|
171
|
+
readonly __wbg_yolopipeline_free: (a: number, b: number) => void;
|
|
91
172
|
readonly pose_palette: (a: number) => void;
|
|
92
173
|
readonly yolomodel_device: (a: number, b: number) => void;
|
|
93
174
|
readonly yolomodel_load_bytes: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
|
|
@@ -95,11 +176,18 @@ export interface InitOutput {
|
|
|
95
176
|
readonly yolomodel_predict: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => number;
|
|
96
177
|
readonly yolomodel_predict_rgba: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => number;
|
|
97
178
|
readonly yolomodel_task: (a: number, b: number) => void;
|
|
179
|
+
readonly yolopipeline_end2end: (a: number) => number;
|
|
180
|
+
readonly yolopipeline_inputShape: (a: number, b: number) => void;
|
|
181
|
+
readonly yolopipeline_names: (a: number, b: number) => void;
|
|
182
|
+
readonly yolopipeline_new: (a: number, b: number, c: number) => void;
|
|
183
|
+
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) => void;
|
|
184
|
+
readonly yolopipeline_preprocess_rgba: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
185
|
+
readonly yolopipeline_task: (a: number, b: number) => void;
|
|
98
186
|
readonly start: () => void;
|
|
99
|
-
readonly
|
|
100
|
-
readonly
|
|
101
|
-
readonly
|
|
102
|
-
readonly
|
|
187
|
+
readonly __wasm_bindgen_func_elem_1961: (a: number, b: number, c: number, d: number) => void;
|
|
188
|
+
readonly __wasm_bindgen_func_elem_2566: (a: number, b: number, c: number, d: number) => void;
|
|
189
|
+
readonly __wasm_bindgen_func_elem_1961_2: (a: number, b: number, c: number, d: number) => void;
|
|
190
|
+
readonly __wasm_bindgen_func_elem_2576: (a: number, b: number, c: number, d: number) => void;
|
|
103
191
|
readonly __wbindgen_export: (a: number, b: number) => number;
|
|
104
192
|
readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
105
193
|
readonly __wbindgen_export3: (a: number) => void;
|
|
@@ -4,10 +4,12 @@ import { trackSessionInit } from './snippets/ort-web-c7b42e3e9fb58316/_telemetry
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* A loaded
|
|
7
|
+
* A loaded ONNX model that runs end to end in wasm (preprocess, inference on
|
|
8
|
+
* ONNX Runtime Web, and postprocess), for the `.onnx` path.
|
|
8
9
|
*
|
|
9
10
|
* Created via [`YoloModel::load_bytes`]; run with [`YoloModel::predict`]. The
|
|
10
|
-
* TypeScript
|
|
11
|
+
* TypeScript `YOLO` class wraps this for ONNX models, and [`YoloPipeline`] for
|
|
12
|
+
* `.tflite` ones.
|
|
11
13
|
*/
|
|
12
14
|
export class YoloModel {
|
|
13
15
|
static __wrap(ptr) {
|
|
@@ -171,6 +173,207 @@ export class YoloModel {
|
|
|
171
173
|
}
|
|
172
174
|
if (Symbol.dispose) YoloModel.prototype[Symbol.dispose] = YoloModel.prototype.free;
|
|
173
175
|
|
|
176
|
+
/**
|
|
177
|
+
* A metadata-only YOLO pre/post pipeline for use with an **external** inference
|
|
178
|
+
* engine (e.g. LiteRT.js running a `.tflite` model in JavaScript).
|
|
179
|
+
*
|
|
180
|
+
* Unlike [`YoloModel`], it holds no ONNX Runtime session: JavaScript loads and
|
|
181
|
+
* runs the model, while this struct reuses the shared Rust preprocessing and
|
|
182
|
+
* postprocessing so results match every other path. Per frame the flow is
|
|
183
|
+
* [`preprocess_rgba`](Self::preprocess_rgba) → (JS engine inference) →
|
|
184
|
+
* [`postprocess`](Self::postprocess). It assumes a single prediction in flight
|
|
185
|
+
* at a time (as the webcam render loop does).
|
|
186
|
+
*/
|
|
187
|
+
export class YoloPipeline {
|
|
188
|
+
__destroy_into_raw() {
|
|
189
|
+
const ptr = this.__wbg_ptr;
|
|
190
|
+
this.__wbg_ptr = 0;
|
|
191
|
+
YoloPipelineFinalization.unregister(this);
|
|
192
|
+
return ptr;
|
|
193
|
+
}
|
|
194
|
+
free() {
|
|
195
|
+
const ptr = this.__destroy_into_raw();
|
|
196
|
+
wasm.__wbg_yolopipeline_free(ptr, 0);
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Whether this is an end-to-end (NMS-free) export, e.g. YOLO26. Its head runs
|
|
200
|
+
* the NMS/top-k with `int64`/`gather_nd` ops that the LiteRT WebGPU delegate
|
|
201
|
+
* cannot execute, so such models must run on the CPU (wasm) accelerator.
|
|
202
|
+
* @returns {boolean}
|
|
203
|
+
*/
|
|
204
|
+
get end2end() {
|
|
205
|
+
const ret = wasm.yolopipeline_end2end(this.__wbg_ptr);
|
|
206
|
+
return ret !== 0;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* The model input shape as `[1, 3, H, W]` (NCHW), for sizing the engine's
|
|
210
|
+
* input tensor. Ultralytics LiteRT exports (`ai_edge_torch`) keep the native
|
|
211
|
+
* NCHW layout, matching the ONNX path.
|
|
212
|
+
* @returns {Uint32Array}
|
|
213
|
+
*/
|
|
214
|
+
get inputShape() {
|
|
215
|
+
try {
|
|
216
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
217
|
+
wasm.yolopipeline_inputShape(retptr, this.__wbg_ptr);
|
|
218
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
219
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
220
|
+
var v1 = getArrayU32FromWasm0(r0, r1).slice();
|
|
221
|
+
wasm.__wbindgen_export4(r0, r1 * 4, 4);
|
|
222
|
+
return v1;
|
|
223
|
+
} finally {
|
|
224
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Class id -> name map (like `model.names`), as a JS object.
|
|
229
|
+
*
|
|
230
|
+
* # Errors
|
|
231
|
+
* Returns a JS error only if serialization fails (not expected).
|
|
232
|
+
* @returns {any}
|
|
233
|
+
*/
|
|
234
|
+
get names() {
|
|
235
|
+
try {
|
|
236
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
237
|
+
wasm.yolopipeline_names(retptr, this.__wbg_ptr);
|
|
238
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
239
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
240
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
241
|
+
if (r2) {
|
|
242
|
+
throw takeObject(r1);
|
|
243
|
+
}
|
|
244
|
+
return takeObject(r0);
|
|
245
|
+
} finally {
|
|
246
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Build a pipeline from a single-file `.tflite` model, reading the
|
|
251
|
+
* Ultralytics metadata (task, class names, `imgsz`, ...) embedded in the
|
|
252
|
+
* model bytes, the same way [`YoloModel::load_bytes`] reads it from an ONNX
|
|
253
|
+
* model, so the ONNX and LiteRT paths load identically from one file.
|
|
254
|
+
*
|
|
255
|
+
* # Errors
|
|
256
|
+
* Returns a JS error if the model carries no Ultralytics metadata or it
|
|
257
|
+
* cannot be parsed.
|
|
258
|
+
* @param {Uint8Array} tflite
|
|
259
|
+
*/
|
|
260
|
+
constructor(tflite) {
|
|
261
|
+
try {
|
|
262
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
263
|
+
const ptr0 = passArray8ToWasm0(tflite, wasm.__wbindgen_export);
|
|
264
|
+
const len0 = WASM_VECTOR_LEN;
|
|
265
|
+
wasm.yolopipeline_new(retptr, ptr0, len0);
|
|
266
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
267
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
268
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
269
|
+
if (r2) {
|
|
270
|
+
throw takeObject(r1);
|
|
271
|
+
}
|
|
272
|
+
this.__wbg_ptr = r0;
|
|
273
|
+
YoloPipelineFinalization.register(this, this.__wbg_ptr, this);
|
|
274
|
+
return this;
|
|
275
|
+
} finally {
|
|
276
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Postprocess an external engine's raw outputs into the standard `Results`.
|
|
281
|
+
*
|
|
282
|
+
* `outputs` are the model's output tensors (one for most tasks; two for
|
|
283
|
+
* segmentation: detection head + mask prototypes). `shapes` encodes each
|
|
284
|
+
* output's dims flat as `[rank0, dims0..., rank1, dims1...]`. `inference_ms`
|
|
285
|
+
* is the time the JS engine reported, used only for the `speed` breakdown.
|
|
286
|
+
* Consumes the frame stashed by the preceding
|
|
287
|
+
* [`preprocess_rgba`](Self::preprocess_rgba).
|
|
288
|
+
*
|
|
289
|
+
* # Errors
|
|
290
|
+
* Returns a JS error if called before `preprocess_rgba`, if `shapes` is
|
|
291
|
+
* malformed, or on serialization failure.
|
|
292
|
+
* @param {Float32Array[]} outputs
|
|
293
|
+
* @param {Uint32Array} shapes
|
|
294
|
+
* @param {number} inference_ms
|
|
295
|
+
* @param {number} conf
|
|
296
|
+
* @param {number} iou
|
|
297
|
+
* @param {Uint32Array | null} [classes]
|
|
298
|
+
* @returns {any}
|
|
299
|
+
*/
|
|
300
|
+
postprocess(outputs, shapes, inference_ms, conf, iou, classes) {
|
|
301
|
+
try {
|
|
302
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
303
|
+
const ptr0 = passArrayJsValueToWasm0(outputs, wasm.__wbindgen_export);
|
|
304
|
+
const len0 = WASM_VECTOR_LEN;
|
|
305
|
+
const ptr1 = passArray32ToWasm0(shapes, wasm.__wbindgen_export);
|
|
306
|
+
const len1 = WASM_VECTOR_LEN;
|
|
307
|
+
var ptr2 = isLikeNone(classes) ? 0 : passArray32ToWasm0(classes, wasm.__wbindgen_export);
|
|
308
|
+
var len2 = WASM_VECTOR_LEN;
|
|
309
|
+
wasm.yolopipeline_postprocess(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, inference_ms, conf, iou, ptr2, len2);
|
|
310
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
311
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
312
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
313
|
+
if (r2) {
|
|
314
|
+
throw takeObject(r1);
|
|
315
|
+
}
|
|
316
|
+
return takeObject(r0);
|
|
317
|
+
} finally {
|
|
318
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Preprocess raw RGBA pixels (e.g. a webcam `ImageData`) into the NCHW f32
|
|
323
|
+
* input tensor an Ultralytics LiteRT/TFLite model expects, normalized to
|
|
324
|
+
* `[0, 1]`, the same preprocessing as the ONNX path.
|
|
325
|
+
*
|
|
326
|
+
* Returns the tensor as a `Float32Array` (shape `[1, 3, H, W]`); the
|
|
327
|
+
* letterbox geometry and original image are stashed for the matching
|
|
328
|
+
* [`postprocess`](Self::postprocess) call.
|
|
329
|
+
*
|
|
330
|
+
* # Errors
|
|
331
|
+
* Returns a JS error if the buffer size is not `width * height * 4`.
|
|
332
|
+
* @param {Uint8Array} rgba
|
|
333
|
+
* @param {number} width
|
|
334
|
+
* @param {number} height
|
|
335
|
+
* @returns {Float32Array}
|
|
336
|
+
*/
|
|
337
|
+
preprocess_rgba(rgba, width, height) {
|
|
338
|
+
try {
|
|
339
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
340
|
+
const ptr0 = passArray8ToWasm0(rgba, wasm.__wbindgen_export);
|
|
341
|
+
const len0 = WASM_VECTOR_LEN;
|
|
342
|
+
wasm.yolopipeline_preprocess_rgba(retptr, this.__wbg_ptr, ptr0, len0, width, height);
|
|
343
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
344
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
345
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
346
|
+
if (r2) {
|
|
347
|
+
throw takeObject(r1);
|
|
348
|
+
}
|
|
349
|
+
return takeObject(r0);
|
|
350
|
+
} finally {
|
|
351
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* The model's task (`"detect"`, `"segment"`, ...).
|
|
356
|
+
* @returns {string}
|
|
357
|
+
*/
|
|
358
|
+
get task() {
|
|
359
|
+
let deferred1_0;
|
|
360
|
+
let deferred1_1;
|
|
361
|
+
try {
|
|
362
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
363
|
+
wasm.yolopipeline_task(retptr, this.__wbg_ptr);
|
|
364
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
365
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
366
|
+
deferred1_0 = r0;
|
|
367
|
+
deferred1_1 = r1;
|
|
368
|
+
return getStringFromWasm0(r0, r1);
|
|
369
|
+
} finally {
|
|
370
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
371
|
+
wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
if (Symbol.dispose) YoloPipeline.prototype[Symbol.dispose] = YoloPipeline.prototype.free;
|
|
376
|
+
|
|
174
377
|
/**
|
|
175
378
|
* Return the Ultralytics pose skeleton + keypoint/limb colors (constant). The
|
|
176
379
|
* JS annotator calls this once to color pose overlays from the shared palette.
|
|
@@ -450,6 +653,10 @@ function __wbg_get_imports() {
|
|
|
450
653
|
const ret = getObject(arg0).length;
|
|
451
654
|
return ret;
|
|
452
655
|
},
|
|
656
|
+
__wbg_length_e6bdba0734e5c7f5: function(arg0) {
|
|
657
|
+
const ret = getObject(arg0).length;
|
|
658
|
+
return ret;
|
|
659
|
+
},
|
|
453
660
|
__wbg_location_40d7e9906760d235: function(arg0) {
|
|
454
661
|
const ret = getObject(arg0).location;
|
|
455
662
|
return (__wbindgen_enum_DataLocation.indexOf(ret) + 1 || 7) - 1;
|
|
@@ -478,6 +685,10 @@ function __wbg_get_imports() {
|
|
|
478
685
|
const ret = new ort.Tensor(__wbindgen_enum_DataType[arg0], takeObject(arg1), takeObject(arg2));
|
|
479
686
|
return addHeapObject(ret);
|
|
480
687
|
}, arguments); },
|
|
688
|
+
__wbg_new_from_slice_6696ab0c133d3f19: function(arg0, arg1) {
|
|
689
|
+
const ret = new Float32Array(getArrayF32FromWasm0(arg0, arg1));
|
|
690
|
+
return addHeapObject(ret);
|
|
691
|
+
},
|
|
481
692
|
__wbg_new_typed_00a409eb4ec4f2d9: function(arg0, arg1) {
|
|
482
693
|
try {
|
|
483
694
|
var state0 = {a: arg0, b: arg1};
|
|
@@ -485,7 +696,7 @@ function __wbg_get_imports() {
|
|
|
485
696
|
const a = state0.a;
|
|
486
697
|
state0.a = 0;
|
|
487
698
|
try {
|
|
488
|
-
return
|
|
699
|
+
return __wasm_bindgen_func_elem_2576(a, state0.b, arg0, arg1);
|
|
489
700
|
} finally {
|
|
490
701
|
state0.a = a;
|
|
491
702
|
}
|
|
@@ -574,6 +785,9 @@ function __wbg_get_imports() {
|
|
|
574
785
|
const ret = getObject(arg0).performance;
|
|
575
786
|
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
576
787
|
},
|
|
788
|
+
__wbg_prototypesetcall_46d9a0b93af9df2d: function(arg0, arg1, arg2) {
|
|
789
|
+
Float32Array.prototype.set.call(getArrayF32FromWasm0(arg0, arg1), getObject(arg2));
|
|
790
|
+
},
|
|
577
791
|
__wbg_prototypesetcall_d721637c7ca66eb8: function(arg0, arg1, arg2) {
|
|
578
792
|
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
|
|
579
793
|
},
|
|
@@ -672,18 +886,18 @@ function __wbg_get_imports() {
|
|
|
672
886
|
return addHeapObject(ret);
|
|
673
887
|
},
|
|
674
888
|
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
675
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx:
|
|
676
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
889
|
+
// 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`.
|
|
890
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_1961);
|
|
677
891
|
return addHeapObject(ret);
|
|
678
892
|
},
|
|
679
893
|
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
680
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx:
|
|
681
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
894
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 916, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
895
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_2566);
|
|
682
896
|
return addHeapObject(ret);
|
|
683
897
|
},
|
|
684
898
|
__wbindgen_cast_0000000000000003: function(arg0, arg1) {
|
|
685
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("boolean")], shim_idx:
|
|
686
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
899
|
+
// 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`.
|
|
900
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_1961_2);
|
|
687
901
|
return addHeapObject(ret);
|
|
688
902
|
},
|
|
689
903
|
__wbindgen_cast_0000000000000004: function(arg0) {
|
|
@@ -770,10 +984,10 @@ function __wbg_get_imports() {
|
|
|
770
984
|
};
|
|
771
985
|
}
|
|
772
986
|
|
|
773
|
-
function
|
|
987
|
+
function __wasm_bindgen_func_elem_1961(arg0, arg1, arg2) {
|
|
774
988
|
try {
|
|
775
989
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
776
|
-
wasm.
|
|
990
|
+
wasm.__wasm_bindgen_func_elem_1961(retptr, arg0, arg1, addHeapObject(arg2));
|
|
777
991
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
778
992
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
779
993
|
if (r1) {
|
|
@@ -784,10 +998,10 @@ function __wasm_bindgen_func_elem_1877(arg0, arg1, arg2) {
|
|
|
784
998
|
}
|
|
785
999
|
}
|
|
786
1000
|
|
|
787
|
-
function
|
|
1001
|
+
function __wasm_bindgen_func_elem_2566(arg0, arg1, arg2) {
|
|
788
1002
|
try {
|
|
789
1003
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
790
|
-
wasm.
|
|
1004
|
+
wasm.__wasm_bindgen_func_elem_2566(retptr, arg0, arg1, addHeapObject(arg2));
|
|
791
1005
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
792
1006
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
793
1007
|
if (r1) {
|
|
@@ -798,10 +1012,10 @@ function __wasm_bindgen_func_elem_2267(arg0, arg1, arg2) {
|
|
|
798
1012
|
}
|
|
799
1013
|
}
|
|
800
1014
|
|
|
801
|
-
function
|
|
1015
|
+
function __wasm_bindgen_func_elem_1961_2(arg0, arg1, arg2) {
|
|
802
1016
|
try {
|
|
803
1017
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
804
|
-
wasm.
|
|
1018
|
+
wasm.__wasm_bindgen_func_elem_1961_2(retptr, arg0, arg1, addHeapObject(arg2));
|
|
805
1019
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
806
1020
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
807
1021
|
if (r1) {
|
|
@@ -812,8 +1026,8 @@ function __wasm_bindgen_func_elem_1877_2(arg0, arg1, arg2) {
|
|
|
812
1026
|
}
|
|
813
1027
|
}
|
|
814
1028
|
|
|
815
|
-
function
|
|
816
|
-
wasm.
|
|
1029
|
+
function __wasm_bindgen_func_elem_2576(arg0, arg1, arg2, arg3) {
|
|
1030
|
+
wasm.__wasm_bindgen_func_elem_2576(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
|
|
817
1031
|
}
|
|
818
1032
|
|
|
819
1033
|
|
|
@@ -824,6 +1038,9 @@ const __wbindgen_enum_DataType = ["bool", "float16", "float32", "float64", "int4
|
|
|
824
1038
|
const YoloModelFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
825
1039
|
? { register: () => {}, unregister: () => {} }
|
|
826
1040
|
: new FinalizationRegistry(ptr => wasm.__wbg_yolomodel_free(ptr, 1));
|
|
1041
|
+
const YoloPipelineFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1042
|
+
? { register: () => {}, unregister: () => {} }
|
|
1043
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_yolopipeline_free(ptr, 1));
|
|
827
1044
|
|
|
828
1045
|
function addHeapObject(obj) {
|
|
829
1046
|
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
Binary file
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
4
|
export const __wbg_yolomodel_free: (a: number, b: number) => void;
|
|
5
|
+
export const __wbg_yolopipeline_free: (a: number, b: number) => void;
|
|
5
6
|
export const pose_palette: (a: number) => void;
|
|
6
7
|
export const yolomodel_device: (a: number, b: number) => void;
|
|
7
8
|
export const yolomodel_load_bytes: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
|
|
@@ -9,11 +10,18 @@ export const yolomodel_names: (a: number, b: number) => void;
|
|
|
9
10
|
export const yolomodel_predict: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => number;
|
|
10
11
|
export const yolomodel_predict_rgba: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => number;
|
|
11
12
|
export const yolomodel_task: (a: number, b: number) => void;
|
|
13
|
+
export const yolopipeline_end2end: (a: number) => number;
|
|
14
|
+
export const yolopipeline_inputShape: (a: number, b: number) => void;
|
|
15
|
+
export const yolopipeline_names: (a: number, b: number) => void;
|
|
16
|
+
export const yolopipeline_new: (a: number, b: number, c: number) => void;
|
|
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) => void;
|
|
18
|
+
export const yolopipeline_preprocess_rgba: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
19
|
+
export const yolopipeline_task: (a: number, b: number) => void;
|
|
12
20
|
export const start: () => void;
|
|
13
|
-
export const
|
|
14
|
-
export const
|
|
15
|
-
export const
|
|
16
|
-
export const
|
|
21
|
+
export const __wasm_bindgen_func_elem_1961: (a: number, b: number, c: number, d: number) => void;
|
|
22
|
+
export const __wasm_bindgen_func_elem_2566: (a: number, b: number, c: number, d: number) => void;
|
|
23
|
+
export const __wasm_bindgen_func_elem_1961_2: (a: number, b: number, c: number, d: number) => void;
|
|
24
|
+
export const __wasm_bindgen_func_elem_2576: (a: number, b: number, c: number, d: number) => void;
|
|
17
25
|
export const __wbindgen_export: (a: number, b: number) => number;
|
|
18
26
|
export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
19
27
|
export const __wbindgen_export3: (a: number) => void;
|