@ultralytics/yolo 0.0.55 → 0.0.57
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 +14 -5
- package/README.zh-CN.md +11 -5
- package/dist/index.d.ts +8 -3
- package/dist/index.js +55 -28
- package/package.json +1 -1
- package/pkg/package.json +1 -1
- package/pkg/ultralytics_inference_web.d.ts +19 -19
- package/pkg/ultralytics_inference_web.js +60 -41
- package/pkg/ultralytics_inference_web_bg.wasm +0 -0
- package/pkg/ultralytics_inference_web_bg.wasm.d.ts +5 -6
package/README.md
CHANGED
|
@@ -82,10 +82,10 @@ await annotate(document.querySelector("canvas"), "bus.jpg", results);
|
|
|
82
82
|
|
|
83
83
|
`predict()` accepts a URL/path, a `Blob`/`File`, raw encoded image bytes
|
|
84
84
|
(`Uint8Array`/`ArrayBuffer`), `ImageData`, an `HTMLImageElement`,
|
|
85
|
-
`HTMLCanvasElement`, `HTMLVideoElement`, or an `ImageBitmap`.
|
|
85
|
+
`HTMLCanvasElement`, `HTMLVideoElement`, an `OffscreenCanvas`, or an `ImageBitmap`.
|
|
86
86
|
|
|
87
87
|
```ts
|
|
88
|
-
const results = await model.predict(canvas, { conf: 0.25, iou: 0.
|
|
88
|
+
const results = await model.predict(canvas, { conf: 0.25, iou: 0.5 });
|
|
89
89
|
console.log(model.device); // "webgpu" or "cpu"
|
|
90
90
|
```
|
|
91
91
|
|
|
@@ -160,9 +160,10 @@ Rust/Ultralytics `Results` API one-to-one:
|
|
|
160
160
|
| `speed` | `{ preprocess, inference, postprocess }` ms | all |
|
|
161
161
|
|
|
162
162
|
`model.names` is the class id to name map (like `model.names` in Python). Every
|
|
163
|
-
detection carries its
|
|
163
|
+
detection carries its class `color` (the model's `colors` metadata entry, else the
|
|
164
|
+
Ultralytics palette), and `annotate()` draws the
|
|
164
165
|
`masks` overlay and the pose skeleton with the same per-limb/keypoint colors as
|
|
165
|
-
the native renderer.
|
|
166
|
+
the native renderer.
|
|
166
167
|
|
|
167
168
|
For the `depth` task, `predict(img, { colormap, depthViz })` picks the colormap
|
|
168
169
|
(`"jet"` default, `"inferno"`, `"spectral"`, `"gray"`) and normalization
|
|
@@ -184,6 +185,10 @@ await annotate(canvas, img, results, { keypointRadius: 4, skeleton: [[0, 1]] });
|
|
|
184
185
|
`annotate()` also takes `lineWidth` and `font` to set the box width and label font, and `labels: false` or
|
|
185
186
|
`keypoints: false` to hide labels or keypoints.
|
|
186
187
|
|
|
188
|
+
Arabic, Hebrew and other right-to-left class names are drawn right to left in every browser, Safari included. They use
|
|
189
|
+
the engine's wasm, so if `annotate()` runs where no model was loaded (for example on the main thread while a worker runs
|
|
190
|
+
the model), pass the same `wasmUrl` you gave `YOLO.load`.
|
|
191
|
+
|
|
187
192
|
## ⚙️ Requirements & Notes
|
|
188
193
|
|
|
189
194
|
- **WebGPU** (Chrome/Edge, or Firefox with WebGPU enabled) from a **secure
|
|
@@ -226,13 +231,16 @@ await annotate(canvas, img, results, { keypointRadius: 4, skeleton: [[0, 1]] });
|
|
|
226
231
|
bundle (~25 MB, browser-cached afterward) from `cdn.pyke.io`. If you set a
|
|
227
232
|
Content-Security-Policy, allow that origin in `script-src`/`connect-src`. To
|
|
228
233
|
avoid the CDN entirely, self-host the runtime and point to it:
|
|
234
|
+
|
|
229
235
|
```ts
|
|
230
236
|
const model = await YOLO.load("/models/yolo26n.onnx", { ortBaseUrl: "/ort/" });
|
|
231
237
|
```
|
|
238
|
+
|
|
232
239
|
The folder must contain the ONNX Runtime Web entry scripts (`ort.webgpu.min.js`
|
|
233
240
|
and `ort.wasm.min.js` for the CPU fallback) plus the
|
|
234
241
|
`ort-wasm-simd-threaded.{jsep,asyncify,}.{mjs,wasm}` binaries. If your bundler does not serve this package's
|
|
235
242
|
own `ultralytics_inference_web_bg.wasm`, pass its URL as `wasmUrl`.
|
|
243
|
+
|
|
236
244
|
- **Telemetry**: `ort-web` can report the page domain to pyke on first session
|
|
237
245
|
creation. This package turns that off, so nothing is sent. See the
|
|
238
246
|
[ort-web docs](https://ort.pyke.io/backends/web) for what it would send.
|
|
@@ -311,7 +319,8 @@ Notes:
|
|
|
311
319
|
- **Tasks**: detect, segment, semantic, depth, classify, pose, and obb are all supported.
|
|
312
320
|
- **Cross-origin isolation**: LiteRT's threaded wasm wants `SharedArrayBuffer`,
|
|
313
321
|
so serve with `Cross-Origin-Opener-Policy: same-origin` and
|
|
314
|
-
`Cross-Origin-Embedder-Policy: require-corp`.
|
|
322
|
+
`Cross-Origin-Embedder-Policy: require-corp`. That blocks the default CDN wasm, so
|
|
323
|
+
pass a same-origin `litertWasmUrl` too.
|
|
315
324
|
|
|
316
325
|
## 🏎️ Benchmarks
|
|
317
326
|
|
package/README.zh-CN.md
CHANGED
|
@@ -79,10 +79,10 @@ await annotate(document.querySelector("canvas"), "bus.jpg", results);
|
|
|
79
79
|
```
|
|
80
80
|
|
|
81
81
|
`predict()` 接受 URL/路径、`Blob`/`File`、原始编码图片字节(`Uint8Array`/`ArrayBuffer`)、
|
|
82
|
-
`ImageData`、`HTMLImageElement`、`HTMLCanvasElement`、`HTMLVideoElement` 或 `ImageBitmap`。
|
|
82
|
+
`ImageData`、`HTMLImageElement`、`HTMLCanvasElement`、`HTMLVideoElement`、`OffscreenCanvas` 或 `ImageBitmap`。
|
|
83
83
|
|
|
84
84
|
```ts
|
|
85
|
-
const results = await model.predict(canvas, { conf: 0.25, iou: 0.
|
|
85
|
+
const results = await model.predict(canvas, { conf: 0.25, iou: 0.5 });
|
|
86
86
|
console.log(model.device); // "webgpu" 或 "cpu"
|
|
87
87
|
```
|
|
88
88
|
|
|
@@ -155,8 +155,8 @@ GitHub release 资源不会返回 `Access-Control-Allow-Origin`,因此浏览
|
|
|
155
155
|
| `speed` | `{ preprocess, inference, postprocess }`,单位 ms | 全部 |
|
|
156
156
|
|
|
157
157
|
`model.names` 是类别 id 到名称的映射(相当于 Python 中的 `model.names`)。每个检测结果都带有
|
|
158
|
-
|
|
159
|
-
|
|
158
|
+
其类别的 `color`(模型 `colors` 元数据中的颜色,否则为 Ultralytics 调色板颜色),`annotate()` 绘制 `masks`
|
|
159
|
+
叠加层和姿态骨架时,使用的每条肢体/关键点配色与原生渲染器完全一致。
|
|
160
160
|
|
|
161
161
|
对于 `depth` 任务,`predict(img, { colormap, depthViz })` 用于选择配色方案(默认 `"jet"`,
|
|
162
162
|
另有 `"inferno"`、`"spectral"`、`"gray"`)和归一化方式(默认 `"disparity"`,另有 `"metric"`);
|
|
@@ -177,6 +177,9 @@ await annotate(canvas, img, results, { keypointRadius: 4, skeleton: [[0, 1]] });
|
|
|
177
177
|
`annotate()` 还接受 `lineWidth` 和 `font` 用于设置框线宽度和标签字体,以及 `labels: false` 或
|
|
178
178
|
`keypoints: false` 用于隐藏标签或关键点。
|
|
179
179
|
|
|
180
|
+
阿拉伯语、希伯来语等从右到左的类别名在所有浏览器(包括 Safari)中都会从右到左绘制。这需要引擎的 wasm,
|
|
181
|
+
因此如果 `annotate()` 运行在未加载模型的线程中(例如模型在 worker 中运行而绘制在主线程),请传入与 `YOLO.load` 相同的 `wasmUrl`。
|
|
182
|
+
|
|
180
183
|
## ⚙️ 环境要求与注意事项
|
|
181
184
|
|
|
182
185
|
- **WebGPU**(Chrome/Edge,或启用了 WebGPU 的 Firefox)配合**安全上下文**(`https://` 或
|
|
@@ -212,12 +215,15 @@ await annotate(canvas, img, results, { keypointRadius: 4, skeleton: [[0, 1]] });
|
|
|
212
215
|
- **运行时资源**:首次加载时,`ort-web` 会从 `cdn.pyke.io` 获取 ONNX Runtime Web 的 wasm 包
|
|
213
216
|
(约 25 MB,之后由浏览器缓存)。如果你设置了 Content-Security-Policy,请在
|
|
214
217
|
`script-src`/`connect-src` 中放行该源。若想完全避开 CDN,可自行托管运行时并指向它:
|
|
218
|
+
|
|
215
219
|
```ts
|
|
216
220
|
const model = await YOLO.load("/models/yolo26n.onnx", { ortBaseUrl: "/ort/" });
|
|
217
221
|
```
|
|
222
|
+
|
|
218
223
|
该目录需包含 ONNX Runtime Web 的入口脚本(`ort.webgpu.min.js`,以及 CPU 回退所需的
|
|
219
224
|
`ort.wasm.min.js`)和 `ort-wasm-simd-threaded.{jsep,asyncify,}.{mjs,wasm}` 二进制文件。如果打包工具没有提供本包自带的
|
|
220
225
|
`ultralytics_inference_web_bg.wasm`,可通过 `wasmUrl` 传入其 URL。
|
|
226
|
+
|
|
221
227
|
- **遥测**:`ort-web` 可以在首次创建会话时向 pyke 上报页面域名。本包已将其关闭,不会发送任何数据。
|
|
222
228
|
上报内容见 [ort-web 文档](https://ort.pyke.io/backends/web)。
|
|
223
229
|
|
|
@@ -288,7 +294,7 @@ wasm 默认从 jsDelivr CDN 加载;向 `YOLO.load` 传入 `litertWasmUrl: "/li
|
|
|
288
294
|
- **支持的任务**:detect、segment、semantic、depth、classify、pose 和 obb 均已支持。
|
|
289
295
|
- **跨源隔离**:LiteRT 的多线程 wasm 需要 `SharedArrayBuffer`,因此请以
|
|
290
296
|
`Cross-Origin-Opener-Policy: same-origin` 和 `Cross-Origin-Embedder-Policy: require-corp`
|
|
291
|
-
|
|
297
|
+
提供服务。这会拦截默认 CDN 上的 wasm,因此还需传入同源的 `litertWasmUrl`。
|
|
292
298
|
|
|
293
299
|
## 🏎️ 基准测试
|
|
294
300
|
|
package/dist/index.d.ts
CHANGED
|
@@ -82,8 +82,8 @@ export interface LoadOptions {
|
|
|
82
82
|
* Optional base URL to self-host the ONNX Runtime Web build instead of
|
|
83
83
|
* fetching it from `cdn.pyke.io`. The directory must contain
|
|
84
84
|
* `ort.webgpu.min.js`, `ort-wasm-simd-threaded.jsep.wasm`, and
|
|
85
|
-
* `ort-wasm-simd-threaded.jsep.mjs` for WebGPU, plus `ort.wasm.min.js
|
|
86
|
-
* `ort-wasm-simd-threaded.wasm` for the CPU build, which is what a `"cpu"`
|
|
85
|
+
* `ort-wasm-simd-threaded.jsep.mjs` for WebGPU, plus `ort.wasm.min.js`,
|
|
86
|
+
* `ort-wasm-simd-threaded.wasm`, and `ort-wasm-simd-threaded.mjs` for the CPU build, which is what a `"cpu"`
|
|
87
87
|
* device and the WebGPU fallback below load. Use an absolute URL ending in `/`.
|
|
88
88
|
*/
|
|
89
89
|
ortBaseUrl?: string | URL;
|
|
@@ -112,7 +112,7 @@ export type ModelSource = string | URL | ArrayBuffer | Uint8Array | Blob;
|
|
|
112
112
|
export interface PredictOptions {
|
|
113
113
|
/** Confidence threshold. Default `0.25` (matches Ultralytics). */
|
|
114
114
|
conf?: number;
|
|
115
|
-
/** NMS IoU threshold. Default `0.
|
|
115
|
+
/** NMS IoU threshold. Default `0.5` (matches Ultralytics predict). */
|
|
116
116
|
iou?: number;
|
|
117
117
|
/**
|
|
118
118
|
* Keep only these class ids. Omit to keep all. Filters detections for
|
|
@@ -159,6 +159,11 @@ export interface AnnotateOptions {
|
|
|
159
159
|
* annotator); `1` shows the raw colorized depth map, `0` shows only the source.
|
|
160
160
|
*/
|
|
161
161
|
depthAlpha?: number;
|
|
162
|
+
/**
|
|
163
|
+
* Optional URL/path to the wasm binary, as in {@link LoadOptions.wasmUrl}. Labels with
|
|
164
|
+
* right-to-left text need the engine, so pass it when no model has loaded it in this thread.
|
|
165
|
+
*/
|
|
166
|
+
wasmUrl?: string | URL;
|
|
162
167
|
}
|
|
163
168
|
/** Image-like inputs accepted by {@link YOLO.predict}. */
|
|
164
169
|
export type ImageInput = string | URL | Blob | ArrayBuffer | Uint8Array | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas | ImageBitmap;
|
package/dist/index.js
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* }
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
|
-
import init, { YoloModel, YoloPipeline, start, pose_palette } from "../pkg/ultralytics_inference_web.js";
|
|
20
|
+
import init, { YoloModel, YoloPipeline, start, pose_palette, bidi_runs } 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() {
|
|
@@ -39,9 +39,7 @@ async function resolveDevice(pref) {
|
|
|
39
39
|
console.warn("[@ultralytics/yolo] WebGPU requested but no adapter found; running on CPU.");
|
|
40
40
|
return "cpu";
|
|
41
41
|
}
|
|
42
|
-
/** Ultralytics default
|
|
43
|
-
const DEFAULT_CONF = 0.25;
|
|
44
|
-
const DEFAULT_IOU = 0.7;
|
|
42
|
+
/** Ultralytics default keypoint confidence threshold for drawing. */
|
|
45
43
|
const DEFAULT_KEYPOINT_THRESHOLD = 0.25;
|
|
46
44
|
/** Whether `bytes` begin with a TFLite flatbuffer (the `TFL3` identifier at offset 4). */
|
|
47
45
|
function isTflite(bytes) {
|
|
@@ -202,10 +200,13 @@ function ensureLiteRtRuntime(litert, wasmUrl) {
|
|
|
202
200
|
litertInitUrl = wasmUrl;
|
|
203
201
|
// Enable WASM multithreading when the page is cross-origin isolated (COOP/COEP
|
|
204
202
|
// set, so SharedArrayBuffer is available); otherwise LiteRT.js runs single-
|
|
205
|
-
// threaded.
|
|
206
|
-
// property, so this needs no per-load option.
|
|
207
|
-
const
|
|
208
|
-
litertInit =
|
|
203
|
+
// threaded. LiteRT's threaded build also needs relaxed SIMD, which Safari lacks.
|
|
204
|
+
// Isolation is a page-global property, so this needs no per-load option.
|
|
205
|
+
const isolated = typeof crossOriginIsolated !== "undefined" && crossOriginIsolated;
|
|
206
|
+
litertInit = (async () => {
|
|
207
|
+
const threads = isolated && (await litert.supportsFeature("relaxedSimd"));
|
|
208
|
+
await litert.loadLiteRt(wasmUrl, { threads });
|
|
209
|
+
})().catch((e) => {
|
|
209
210
|
litertInit = null; // let a later load retry if the first init failed
|
|
210
211
|
litertInitUrl = null;
|
|
211
212
|
throw e;
|
|
@@ -320,21 +321,18 @@ class LiteRtEngine {
|
|
|
320
321
|
get names() {
|
|
321
322
|
return this.pipeline.names;
|
|
322
323
|
}
|
|
323
|
-
predictDrawable(data, width, height, p) {
|
|
324
|
-
return this.runDrawable(data, width, height, p);
|
|
325
|
-
}
|
|
326
324
|
/** LiteRT takes raw pixels, so decode encoded inputs to RGBA in JS first. */
|
|
327
325
|
async predictEncoded(bytes, p) {
|
|
328
326
|
const bitmap = await createImageBitmap(new Blob([bytes]));
|
|
329
327
|
try {
|
|
330
328
|
const { data, width, height } = toImageData(bitmap);
|
|
331
|
-
return await this.
|
|
329
|
+
return await this.predictDrawable(data, width, height, p);
|
|
332
330
|
}
|
|
333
331
|
finally {
|
|
334
332
|
bitmap.close();
|
|
335
333
|
}
|
|
336
334
|
}
|
|
337
|
-
async
|
|
335
|
+
async predictDrawable(data, width, height, p) {
|
|
338
336
|
const input = this.pipeline.preprocess_rgba(data, width, height);
|
|
339
337
|
const { outputs, shapes, inferenceMs } = await this.backend.run(input, Array.from(this.pipeline.inputShape));
|
|
340
338
|
return this.pipeline.postprocess(outputs, shapes.map((s) => new Uint32Array(s)), inferenceMs, p.conf, p.iou, p.classes, p.colormap, p.depthViz);
|
|
@@ -418,8 +416,9 @@ export class YOLO {
|
|
|
418
416
|
*/
|
|
419
417
|
async predict(image, options) {
|
|
420
418
|
const p = {
|
|
421
|
-
|
|
422
|
-
|
|
419
|
+
// Unset thresholds fall back to the Rust `InferenceConfig` defaults.
|
|
420
|
+
conf: options?.conf,
|
|
421
|
+
iou: options?.iou,
|
|
423
422
|
classes: options?.classes ? new Uint32Array(options.classes) : undefined,
|
|
424
423
|
// Empty means "unset": the wasm side falls back to the Rust `Colormap`/`DepthViz`
|
|
425
424
|
// defaults, so the default lives in exactly one place.
|
|
@@ -448,15 +447,12 @@ export class YOLO {
|
|
|
448
447
|
this.engine.free();
|
|
449
448
|
}
|
|
450
449
|
}
|
|
451
|
-
|
|
452
|
-
// so there is no palette duplicated here.
|
|
453
|
-
/** Pick black or white text for readability over a given hex background. */
|
|
450
|
+
/** Label text color over a `#rrggbb` background, the rule of `Color::text_color` in the engine. */
|
|
454
451
|
function textColorFor(hex) {
|
|
455
452
|
const r = parseInt(hex.slice(1, 3), 16);
|
|
456
453
|
const g = parseInt(hex.slice(3, 5), 16);
|
|
457
454
|
const b = parseInt(hex.slice(5, 7), 16);
|
|
458
|
-
|
|
459
|
-
return r * 0.299 + g * 0.587 + b * 0.114 > 140 ? "#000000" : "#FFFFFF";
|
|
455
|
+
return r * 0.299 + g * 0.587 + b * 0.114 > 150 ? "#111F68" : "#FFFFFF";
|
|
460
456
|
}
|
|
461
457
|
/**
|
|
462
458
|
* Draw inference results onto a canvas, on top of the source image.
|
|
@@ -511,17 +507,47 @@ export async function annotate(canvas, image, results, options) {
|
|
|
511
507
|
ctx.lineWidth = lineWidth;
|
|
512
508
|
ctx.font = font;
|
|
513
509
|
ctx.textBaseline = "top";
|
|
510
|
+
ctx.textAlign = "left";
|
|
511
|
+
// Labels that may hold right-to-left text (Unicode's right-to-left blocks and controls) are
|
|
512
|
+
// drawn as the engine's bidi runs, each in its resolved direction, since Safari's canvas
|
|
513
|
+
// does not pair brackets in right-to-left text. Other labels read left to right as they are.
|
|
514
|
+
const rtlText = /[\u0590-\u08FF\u200F\u202B\u202E\u2067\u2068\uFB1D-\uFDFF\uFE70-\uFEFF\u{10800}-\u{10FFF}\u{1E800}-\u{1EFFF}]/u;
|
|
515
|
+
const names = [...results.boxes, ...results.obb].map((b) => b.name);
|
|
516
|
+
if (showLabels && names.concat(results.probs?.top5names ?? []).some((n) => rtlText.test(n))) {
|
|
517
|
+
await ensureInit(options?.wasmUrl);
|
|
518
|
+
}
|
|
519
|
+
// Class names repeat across labels, so each run's width is measured once per call.
|
|
520
|
+
const widths = new Map();
|
|
521
|
+
const layout = (text) => (rtlText.test(text) ? bidi_runs(text) : [text]).map((run) => {
|
|
522
|
+
const rtl = run.startsWith("\u202E");
|
|
523
|
+
let width = widths.get(run);
|
|
524
|
+
if (width === undefined) {
|
|
525
|
+
ctx.direction = rtl ? "rtl" : "ltr";
|
|
526
|
+
width = ctx.measureText(run).width;
|
|
527
|
+
widths.set(run, width);
|
|
528
|
+
}
|
|
529
|
+
return { text: run, rtl, width };
|
|
530
|
+
});
|
|
531
|
+
const runsWidth = (runs) => runs.reduce((sum, run) => sum + run.width, 0);
|
|
532
|
+
const fillText = (runs, x, y) => {
|
|
533
|
+
for (const run of runs) {
|
|
534
|
+
ctx.direction = run.rtl ? "rtl" : "ltr";
|
|
535
|
+
ctx.fillText(run.text, x, y);
|
|
536
|
+
x += run.width;
|
|
537
|
+
}
|
|
538
|
+
};
|
|
514
539
|
const label = (text, x, y, color) => {
|
|
515
540
|
if (!showLabels)
|
|
516
541
|
return;
|
|
517
542
|
const pad = Math.round(fontSize * 0.2);
|
|
518
|
-
const
|
|
543
|
+
const runs = layout(text);
|
|
544
|
+
const w = runsWidth(runs) + pad * 2;
|
|
519
545
|
const h = fontSize + pad * 2;
|
|
520
546
|
const ly = Math.max(0, y - h);
|
|
521
547
|
ctx.fillStyle = color;
|
|
522
548
|
ctx.fillRect(x, ly, w, h);
|
|
523
549
|
ctx.fillStyle = textColorFor(color);
|
|
524
|
-
|
|
550
|
+
fillText(runs, x + pad, ly + pad);
|
|
525
551
|
};
|
|
526
552
|
// Axis-aligned boxes (detect / segment / pose).
|
|
527
553
|
for (const b of results.boxes) {
|
|
@@ -561,19 +587,20 @@ export async function annotate(canvas, image, results, options) {
|
|
|
561
587
|
ctx.lineWidth = Math.max(1, Math.round(lineWidth / 1.5));
|
|
562
588
|
for (const kp of results.keypoints) {
|
|
563
589
|
// Like Ultralytics, only the 17-keypoint COCO-Pose layout gets the pose palette and the
|
|
564
|
-
// human skeleton; other layouts take one palette color per keypoint and no lines
|
|
590
|
+
// human skeleton; other layouts take one class palette color per keypoint and no lines,
|
|
591
|
+
// and a custom skeleton colors each line like its start keypoint.
|
|
565
592
|
const coco = kp.points.length === scheme.keypoint_colors.length;
|
|
566
593
|
const skeleton = options?.skeleton ?? (coco ? scheme.skeleton : []);
|
|
567
594
|
const paletteAt = (i) => scheme.palette[i % scheme.palette.length];
|
|
568
|
-
const limbColor = (i) => fixed ?? (coco && !options?.skeleton ? scheme.limb_colors[i] : paletteAt(i));
|
|
569
595
|
const kptColor = (i) => fixed ?? (coco ? scheme.keypoint_colors[i] : paletteAt(i));
|
|
596
|
+
const limbColor = (i, a) => coco && !options?.skeleton ? (fixed ?? scheme.limb_colors[i]) : kptColor(a);
|
|
570
597
|
if (options?.keypointLines ?? true) {
|
|
571
598
|
skeleton.forEach(([a, b], li) => {
|
|
572
599
|
const pa = kp.points[a];
|
|
573
600
|
const pb = kp.points[b];
|
|
574
601
|
if (!pa || !pb || pa[2] < kptThresh || pb[2] < kptThresh)
|
|
575
602
|
return;
|
|
576
|
-
ctx.strokeStyle = limbColor(li);
|
|
603
|
+
ctx.strokeStyle = limbColor(li, a);
|
|
577
604
|
ctx.beginPath();
|
|
578
605
|
ctx.moveTo(pa[0], pa[1]);
|
|
579
606
|
ctx.lineTo(pb[0], pb[1]);
|
|
@@ -595,15 +622,15 @@ export async function annotate(canvas, image, results, options) {
|
|
|
595
622
|
// and Python renderers, which list the top classes rather than a single banner).
|
|
596
623
|
if (results.probs && showLabels) {
|
|
597
624
|
const { top5, top5conf, top5names } = results.probs;
|
|
598
|
-
const lines = top5.map((_, i) => `${top5names[i] ?? top5[i]} ${top5conf[i].toFixed(2)}`);
|
|
625
|
+
const lines = top5.map((_, i) => layout(`${top5names[i] ?? top5[i]} ${top5conf[i].toFixed(2)}`));
|
|
599
626
|
const pad = Math.round(fontSize * 0.3);
|
|
600
627
|
const lineH = Math.round(fontSize * 1.25);
|
|
601
|
-
const boxW = Math.max(...lines.map(
|
|
628
|
+
const boxW = Math.max(...lines.map(runsWidth)) + pad * 2;
|
|
602
629
|
const boxH = lines.length * lineH + pad * 2;
|
|
603
630
|
ctx.fillStyle = "rgba(0, 0, 0, 0.4)";
|
|
604
631
|
ctx.fillRect(pad, pad, boxW, boxH);
|
|
605
632
|
ctx.fillStyle = "#ffffff";
|
|
606
|
-
lines.forEach((t, i) =>
|
|
633
|
+
lines.forEach((t, i) => fillText(t, pad * 2, pad * 2 + i * lineH));
|
|
607
634
|
}
|
|
608
635
|
}
|
|
609
636
|
/** Resolve any {@link ImageInput} to something `drawImage` accepts. */
|
package/package.json
CHANGED
package/pkg/package.json
CHANGED
|
@@ -33,15 +33,15 @@ export class YoloModel {
|
|
|
33
33
|
/**
|
|
34
34
|
* Run inference on a single encoded image (JPEG or PNG bytes).
|
|
35
35
|
*
|
|
36
|
-
* `conf` and `iou` are the confidence and NMS IoU thresholds (
|
|
37
|
-
* defaults 0.25 / 0.
|
|
36
|
+
* `conf` and `iou` are the confidence and NMS IoU thresholds (omit them for the
|
|
37
|
+
* Ultralytics defaults 0.25 / 0.5); `classes` optionally keeps only
|
|
38
38
|
* the given class ids (for semantic, other pixels become background).
|
|
39
39
|
* Returns a plain JS object whose shape mirrors the Ultralytics `Results` API.
|
|
40
40
|
*
|
|
41
41
|
* # Errors
|
|
42
42
|
* Returns a JS error if the image cannot be decoded or inference fails.
|
|
43
43
|
*/
|
|
44
|
-
predict(image: Uint8Array, conf: number, iou: number, classes: Uint32Array | null | undefined, colormap: string, depth_viz: string): Promise<any>;
|
|
44
|
+
predict(image: Uint8Array, conf: number | null | undefined, iou: number | null | undefined, classes: Uint32Array | null | undefined, colormap: string, depth_viz: string): Promise<any>;
|
|
45
45
|
/**
|
|
46
46
|
* Run inference on raw `RGBA` pixels (e.g. a canvas/webcam `ImageData`).
|
|
47
47
|
*
|
|
@@ -51,7 +51,7 @@ export class YoloModel {
|
|
|
51
51
|
* # Errors
|
|
52
52
|
* Returns a JS error if the buffer size is wrong or inference fails.
|
|
53
53
|
*/
|
|
54
|
-
predict_rgba(rgba: Uint8Array, width: number, height: number, conf: number, iou: number, classes: Uint32Array | null | undefined, colormap: string, depth_viz: string): Promise<any>;
|
|
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>;
|
|
55
55
|
/**
|
|
56
56
|
* The active device: `"webgpu"` or `"cpu"` (the fallback when WebGPU is
|
|
57
57
|
* unavailable). Mirrors the native `Device` display.
|
|
@@ -110,7 +110,7 @@ export class YoloPipeline {
|
|
|
110
110
|
* Returns a JS error if called before `preprocess_rgba`, if `shapes` does not
|
|
111
111
|
* have one entry per output, or on serialization failure.
|
|
112
112
|
*/
|
|
113
|
-
postprocess(outputs: Float32Array[], shapes: Uint32Array[], inference_ms: number, conf: number, iou: number, classes: Uint32Array | null | undefined, colormap: string, depth_viz: string): any;
|
|
113
|
+
postprocess(outputs: Float32Array[], shapes: Uint32Array[], inference_ms: number, conf: number | null | undefined, iou: number | null | undefined, classes: Uint32Array | null | undefined, colormap: string, depth_viz: string): any;
|
|
114
114
|
/**
|
|
115
115
|
* Preprocess raw RGBA pixels (e.g. a webcam `ImageData`) into the NCHW f32
|
|
116
116
|
* input tensor an Ultralytics LiteRT/TFLite model expects, normalized to
|
|
@@ -139,10 +139,6 @@ export class YoloPipeline {
|
|
|
139
139
|
* the metadata size in place.
|
|
140
140
|
*/
|
|
141
141
|
setInputShape(shape: Int32Array): void;
|
|
142
|
-
/**
|
|
143
|
-
* Whether this is an NMS-free export, e.g. YOLO26 with `nms=False`.
|
|
144
|
-
*/
|
|
145
|
-
readonly end2end: boolean;
|
|
146
142
|
/**
|
|
147
143
|
* The model input shape as `[1, 3, H, W]` (NCHW), for sizing the engine's
|
|
148
144
|
* input tensor. Ultralytics LiteRT exports (`ai_edge_torch`) keep the native
|
|
@@ -156,16 +152,21 @@ export class YoloPipeline {
|
|
|
156
152
|
* Returns a JS error only if serialization fails (not expected).
|
|
157
153
|
*/
|
|
158
154
|
readonly names: any;
|
|
159
|
-
/**
|
|
160
|
-
* Whether this is an RT-DETR export.
|
|
161
|
-
*/
|
|
162
|
-
readonly rtdetr: boolean;
|
|
163
155
|
/**
|
|
164
156
|
* The model's task (`"detect"`, `"segment"`, ...).
|
|
165
157
|
*/
|
|
166
158
|
readonly task: string;
|
|
167
159
|
}
|
|
168
160
|
|
|
161
|
+
/**
|
|
162
|
+
* Split a label into runs in left-to-right display order (Unicode bidi algorithm), each wrapped
|
|
163
|
+
* in a left-to-right or right-to-left override so canvas draws it in its resolved direction. The
|
|
164
|
+
* JS annotator draws runs one by one because Safari's canvas does not pair brackets in
|
|
165
|
+
* right-to-left text. Explicit embeddings, overrides and isolates are dropped, since the
|
|
166
|
+
* resolved levels already carry them.
|
|
167
|
+
*/
|
|
168
|
+
export function bidi_runs(text: string): string[];
|
|
169
|
+
|
|
169
170
|
/**
|
|
170
171
|
* Return the Ultralytics pose skeleton + keypoint/limb colors (constant). The
|
|
171
172
|
* JS annotator calls this once to color pose overlays from the shared palette.
|
|
@@ -186,6 +187,7 @@ export interface InitOutput {
|
|
|
186
187
|
readonly memory: WebAssembly.Memory;
|
|
187
188
|
readonly __wbg_yolomodel_free: (a: number, b: number) => void;
|
|
188
189
|
readonly __wbg_yolopipeline_free: (a: number, b: number) => void;
|
|
190
|
+
readonly bidi_runs: (a: number, b: number, c: number) => void;
|
|
189
191
|
readonly pose_palette: (a: number) => void;
|
|
190
192
|
readonly start: () => void;
|
|
191
193
|
readonly yolomodel_device: (a: number, b: number) => void;
|
|
@@ -194,19 +196,17 @@ export interface InitOutput {
|
|
|
194
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;
|
|
195
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;
|
|
196
198
|
readonly yolomodel_task: (a: number, b: number) => void;
|
|
197
|
-
readonly yolopipeline_end2end: (a: number) => number;
|
|
198
199
|
readonly yolopipeline_inputShape: (a: number, b: number) => void;
|
|
199
200
|
readonly yolopipeline_names: (a: number, b: number) => void;
|
|
200
201
|
readonly yolopipeline_new: (a: number, b: number, c: number) => void;
|
|
201
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;
|
|
202
203
|
readonly yolopipeline_preprocess_rgba: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
203
|
-
readonly yolopipeline_rtdetr: (a: number) => number;
|
|
204
204
|
readonly yolopipeline_setInputShape: (a: number, b: number, c: number) => void;
|
|
205
205
|
readonly yolopipeline_task: (a: number, b: number) => void;
|
|
206
|
-
readonly
|
|
207
|
-
readonly
|
|
208
|
-
readonly
|
|
209
|
-
readonly
|
|
206
|
+
readonly __wasm_bindgen_func_elem_1232: (a: number, b: number, c: number, d: number) => void;
|
|
207
|
+
readonly __wasm_bindgen_func_elem_1863: (a: number, b: number, c: number, d: number) => void;
|
|
208
|
+
readonly __wasm_bindgen_func_elem_1887: (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;
|
|
210
210
|
readonly __wbindgen_export: (a: number, b: number) => number;
|
|
211
211
|
readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
212
212
|
readonly __wbindgen_export3: (a: number) => void;
|
|
@@ -104,16 +104,16 @@ export class YoloModel {
|
|
|
104
104
|
/**
|
|
105
105
|
* Run inference on a single encoded image (JPEG or PNG bytes).
|
|
106
106
|
*
|
|
107
|
-
* `conf` and `iou` are the confidence and NMS IoU thresholds (
|
|
108
|
-
* defaults 0.25 / 0.
|
|
107
|
+
* `conf` and `iou` are the confidence and NMS IoU thresholds (omit them for the
|
|
108
|
+
* Ultralytics defaults 0.25 / 0.5); `classes` optionally keeps only
|
|
109
109
|
* the given class ids (for semantic, other pixels become background).
|
|
110
110
|
* Returns a plain JS object whose shape mirrors the Ultralytics `Results` API.
|
|
111
111
|
*
|
|
112
112
|
* # Errors
|
|
113
113
|
* Returns a JS error if the image cannot be decoded or inference fails.
|
|
114
114
|
* @param {Uint8Array} image
|
|
115
|
-
* @param {number} conf
|
|
116
|
-
* @param {number} iou
|
|
115
|
+
* @param {number | null | undefined} conf
|
|
116
|
+
* @param {number | null | undefined} iou
|
|
117
117
|
* @param {Uint32Array | null | undefined} classes
|
|
118
118
|
* @param {string} colormap
|
|
119
119
|
* @param {string} depth_viz
|
|
@@ -128,7 +128,7 @@ export class YoloModel {
|
|
|
128
128
|
const len2 = WASM_VECTOR_LEN;
|
|
129
129
|
const ptr3 = passStringToWasm0(depth_viz, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
130
130
|
const len3 = WASM_VECTOR_LEN;
|
|
131
|
-
const ret = wasm.yolomodel_predict(this.__wbg_ptr, ptr0, len0, conf, iou, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
131
|
+
const ret = wasm.yolomodel_predict(this.__wbg_ptr, ptr0, len0, isLikeNone(conf) ? Number.MAX_SAFE_INTEGER : Math.fround(conf), isLikeNone(iou) ? Number.MAX_SAFE_INTEGER : Math.fround(iou), ptr1, len1, ptr2, len2, ptr3, len3);
|
|
132
132
|
return takeObject(ret);
|
|
133
133
|
}
|
|
134
134
|
/**
|
|
@@ -142,8 +142,8 @@ export class YoloModel {
|
|
|
142
142
|
* @param {Uint8Array} rgba
|
|
143
143
|
* @param {number} width
|
|
144
144
|
* @param {number} height
|
|
145
|
-
* @param {number} conf
|
|
146
|
-
* @param {number} iou
|
|
145
|
+
* @param {number | null | undefined} conf
|
|
146
|
+
* @param {number | null | undefined} iou
|
|
147
147
|
* @param {Uint32Array | null | undefined} classes
|
|
148
148
|
* @param {string} colormap
|
|
149
149
|
* @param {string} depth_viz
|
|
@@ -158,7 +158,7 @@ export class YoloModel {
|
|
|
158
158
|
const len2 = WASM_VECTOR_LEN;
|
|
159
159
|
const ptr3 = passStringToWasm0(depth_viz, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
160
160
|
const len3 = WASM_VECTOR_LEN;
|
|
161
|
-
const ret = wasm.yolomodel_predict_rgba(this.__wbg_ptr, ptr0, len0, width, height, conf, iou, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
161
|
+
const ret = wasm.yolomodel_predict_rgba(this.__wbg_ptr, ptr0, len0, width, height, isLikeNone(conf) ? Number.MAX_SAFE_INTEGER : Math.fround(conf), isLikeNone(iou) ? Number.MAX_SAFE_INTEGER : Math.fround(iou), ptr1, len1, ptr2, len2, ptr3, len3);
|
|
162
162
|
return takeObject(ret);
|
|
163
163
|
}
|
|
164
164
|
/**
|
|
@@ -207,14 +207,6 @@ export class YoloPipeline {
|
|
|
207
207
|
const ptr = this.__destroy_into_raw();
|
|
208
208
|
wasm.__wbg_yolopipeline_free(ptr, 0);
|
|
209
209
|
}
|
|
210
|
-
/**
|
|
211
|
-
* Whether this is an NMS-free export, e.g. YOLO26 with `nms=False`.
|
|
212
|
-
* @returns {boolean}
|
|
213
|
-
*/
|
|
214
|
-
get end2end() {
|
|
215
|
-
const ret = wasm.yolopipeline_end2end(this.__wbg_ptr);
|
|
216
|
-
return ret !== 0;
|
|
217
|
-
}
|
|
218
210
|
/**
|
|
219
211
|
* The model input shape as `[1, 3, H, W]` (NCHW), for sizing the engine's
|
|
220
212
|
* input tensor. Ultralytics LiteRT exports (`ai_edge_torch`) keep the native
|
|
@@ -302,8 +294,8 @@ export class YoloPipeline {
|
|
|
302
294
|
* @param {Float32Array[]} outputs
|
|
303
295
|
* @param {Uint32Array[]} shapes
|
|
304
296
|
* @param {number} inference_ms
|
|
305
|
-
* @param {number} conf
|
|
306
|
-
* @param {number} iou
|
|
297
|
+
* @param {number | null | undefined} conf
|
|
298
|
+
* @param {number | null | undefined} iou
|
|
307
299
|
* @param {Uint32Array | null | undefined} classes
|
|
308
300
|
* @param {string} colormap
|
|
309
301
|
* @param {string} depth_viz
|
|
@@ -322,7 +314,7 @@ export class YoloPipeline {
|
|
|
322
314
|
const len3 = WASM_VECTOR_LEN;
|
|
323
315
|
const ptr4 = passStringToWasm0(depth_viz, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
324
316
|
const len4 = WASM_VECTOR_LEN;
|
|
325
|
-
wasm.yolopipeline_postprocess(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, inference_ms, conf, iou, ptr2, len2, ptr3, len3, ptr4, len4);
|
|
317
|
+
wasm.yolopipeline_postprocess(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, inference_ms, isLikeNone(conf) ? Number.MAX_SAFE_INTEGER : Math.fround(conf), isLikeNone(iou) ? Number.MAX_SAFE_INTEGER : Math.fround(iou), ptr2, len2, ptr3, len3, ptr4, len4);
|
|
326
318
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
327
319
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
328
320
|
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
@@ -367,14 +359,6 @@ export class YoloPipeline {
|
|
|
367
359
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
368
360
|
}
|
|
369
361
|
}
|
|
370
|
-
/**
|
|
371
|
-
* Whether this is an RT-DETR export.
|
|
372
|
-
* @returns {boolean}
|
|
373
|
-
*/
|
|
374
|
-
get rtdetr() {
|
|
375
|
-
const ret = wasm.yolopipeline_rtdetr(this.__wbg_ptr);
|
|
376
|
-
return ret !== 0;
|
|
377
|
-
}
|
|
378
362
|
/**
|
|
379
363
|
* Adopt the input shape the engine reports for the compiled model.
|
|
380
364
|
*
|
|
@@ -418,6 +402,31 @@ export class YoloPipeline {
|
|
|
418
402
|
}
|
|
419
403
|
if (Symbol.dispose) YoloPipeline.prototype[Symbol.dispose] = YoloPipeline.prototype.free;
|
|
420
404
|
|
|
405
|
+
/**
|
|
406
|
+
* Split a label into runs in left-to-right display order (Unicode bidi algorithm), each wrapped
|
|
407
|
+
* in a left-to-right or right-to-left override so canvas draws it in its resolved direction. The
|
|
408
|
+
* JS annotator draws runs one by one because Safari's canvas does not pair brackets in
|
|
409
|
+
* right-to-left text. Explicit embeddings, overrides and isolates are dropped, since the
|
|
410
|
+
* resolved levels already carry them.
|
|
411
|
+
* @param {string} text
|
|
412
|
+
* @returns {string[]}
|
|
413
|
+
*/
|
|
414
|
+
export function bidi_runs(text) {
|
|
415
|
+
try {
|
|
416
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
417
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
418
|
+
const len0 = WASM_VECTOR_LEN;
|
|
419
|
+
wasm.bidi_runs(retptr, ptr0, len0);
|
|
420
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
421
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
422
|
+
var v2 = getArrayJsValueFromWasm0(r0, r1);
|
|
423
|
+
wasm.__wbindgen_export4(r0, r1 * 4, 4);
|
|
424
|
+
return v2;
|
|
425
|
+
} finally {
|
|
426
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
|
|
421
430
|
/**
|
|
422
431
|
* Return the Ultralytics pose skeleton + keypoint/limb colors (constant). The
|
|
423
432
|
* JS annotator calls this once to color pose overlays from the shared palette.
|
|
@@ -755,7 +764,7 @@ function __wbg_get_imports() {
|
|
|
755
764
|
const a = state0.a;
|
|
756
765
|
state0.a = 0;
|
|
757
766
|
try {
|
|
758
|
-
return
|
|
767
|
+
return __wasm_bindgen_func_elem_1887(a, state0.b, arg0, arg1);
|
|
759
768
|
} finally {
|
|
760
769
|
state0.a = a;
|
|
761
770
|
}
|
|
@@ -947,18 +956,18 @@ function __wbg_get_imports() {
|
|
|
947
956
|
return addHeapObject(ret);
|
|
948
957
|
},
|
|
949
958
|
__wbindgen_generic_0000000000000001: function(arg0, arg1) {
|
|
950
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx:
|
|
951
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
959
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 371, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
960
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_1232);
|
|
952
961
|
return addHeapObject(ret);
|
|
953
962
|
},
|
|
954
963
|
__wbindgen_generic_0000000000000002: function(arg0, arg1) {
|
|
955
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx:
|
|
956
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
964
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 655, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
965
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_1863);
|
|
957
966
|
return addHeapObject(ret);
|
|
958
967
|
},
|
|
959
968
|
__wbindgen_generic_0000000000000003: function(arg0, arg1) {
|
|
960
969
|
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("boolean")], shim_idx: 21, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
961
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
970
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_382);
|
|
962
971
|
return addHeapObject(ret);
|
|
963
972
|
},
|
|
964
973
|
__wbindgen_generic_0000000000000004: function(arg0) {
|
|
@@ -1045,14 +1054,14 @@ function __wbg_get_imports() {
|
|
|
1045
1054
|
};
|
|
1046
1055
|
}
|
|
1047
1056
|
|
|
1048
|
-
function
|
|
1049
|
-
wasm.
|
|
1057
|
+
function __wasm_bindgen_func_elem_1887(arg0, arg1, arg2, arg3) {
|
|
1058
|
+
wasm.__wasm_bindgen_func_elem_1887(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
|
|
1050
1059
|
}
|
|
1051
1060
|
|
|
1052
|
-
function
|
|
1061
|
+
function __wasm_bindgen_func_elem_1232(arg0, arg1, arg2) {
|
|
1053
1062
|
try {
|
|
1054
1063
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1055
|
-
wasm.
|
|
1064
|
+
wasm.__wasm_bindgen_func_elem_1232(retptr, arg0, arg1, addHeapObject(arg2));
|
|
1056
1065
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1057
1066
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1058
1067
|
if (r1) {
|
|
@@ -1063,10 +1072,10 @@ function __wasm_bindgen_func_elem_1192(arg0, arg1, arg2) {
|
|
|
1063
1072
|
}
|
|
1064
1073
|
}
|
|
1065
1074
|
|
|
1066
|
-
function
|
|
1075
|
+
function __wasm_bindgen_func_elem_1863(arg0, arg1, arg2) {
|
|
1067
1076
|
try {
|
|
1068
1077
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1069
|
-
wasm.
|
|
1078
|
+
wasm.__wasm_bindgen_func_elem_1863(retptr, arg0, arg1, addHeapObject(arg2));
|
|
1070
1079
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1071
1080
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1072
1081
|
if (r1) {
|
|
@@ -1077,10 +1086,10 @@ function __wasm_bindgen_func_elem_1823(arg0, arg1, arg2) {
|
|
|
1077
1086
|
}
|
|
1078
1087
|
}
|
|
1079
1088
|
|
|
1080
|
-
function
|
|
1089
|
+
function __wasm_bindgen_func_elem_382(arg0, arg1, arg2) {
|
|
1081
1090
|
try {
|
|
1082
1091
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1083
|
-
wasm.
|
|
1092
|
+
wasm.__wasm_bindgen_func_elem_382(retptr, arg0, arg1, addHeapObject(arg2));
|
|
1084
1093
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1085
1094
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1086
1095
|
if (r1) {
|
|
@@ -1217,6 +1226,16 @@ function getArrayI8FromWasm0(ptr, len) {
|
|
|
1217
1226
|
return getInt8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
1218
1227
|
}
|
|
1219
1228
|
|
|
1229
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
1230
|
+
ptr = ptr >>> 0;
|
|
1231
|
+
const mem = getDataViewMemory0();
|
|
1232
|
+
const result = [];
|
|
1233
|
+
for (let i = ptr; i < ptr + 4 * len; i += 4) {
|
|
1234
|
+
result.push(takeObject(mem.getUint32(i, true)));
|
|
1235
|
+
}
|
|
1236
|
+
return result;
|
|
1237
|
+
}
|
|
1238
|
+
|
|
1220
1239
|
function getArrayU16FromWasm0(ptr, len) {
|
|
1221
1240
|
ptr = ptr >>> 0;
|
|
1222
1241
|
return getUint16ArrayMemory0().subarray(ptr / 2, ptr / 2 + len);
|
|
Binary file
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
4
|
export const __wbg_yolomodel_free: (a: number, b: number) => void;
|
|
5
5
|
export const __wbg_yolopipeline_free: (a: number, b: number) => void;
|
|
6
|
+
export const bidi_runs: (a: number, b: number, c: number) => void;
|
|
6
7
|
export const pose_palette: (a: number) => void;
|
|
7
8
|
export const start: () => void;
|
|
8
9
|
export const yolomodel_device: (a: number, b: number) => void;
|
|
@@ -11,19 +12,17 @@ export const yolomodel_names: (a: number, b: number) => void;
|
|
|
11
12
|
export const 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;
|
|
12
13
|
export const 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;
|
|
13
14
|
export const yolomodel_task: (a: number, b: number) => void;
|
|
14
|
-
export const yolopipeline_end2end: (a: number) => number;
|
|
15
15
|
export const yolopipeline_inputShape: (a: number, b: number) => void;
|
|
16
16
|
export const yolopipeline_names: (a: number, b: number) => void;
|
|
17
17
|
export const yolopipeline_new: (a: number, b: number, c: number) => void;
|
|
18
18
|
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;
|
|
19
19
|
export const yolopipeline_preprocess_rgba: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
20
|
-
export const yolopipeline_rtdetr: (a: number) => number;
|
|
21
20
|
export const yolopipeline_setInputShape: (a: number, b: number, c: number) => void;
|
|
22
21
|
export const yolopipeline_task: (a: number, b: number) => void;
|
|
23
|
-
export const
|
|
24
|
-
export const
|
|
25
|
-
export const
|
|
26
|
-
export const
|
|
22
|
+
export const __wasm_bindgen_func_elem_1232: (a: number, b: number, c: number, d: number) => void;
|
|
23
|
+
export const __wasm_bindgen_func_elem_1863: (a: number, b: number, c: number, d: number) => void;
|
|
24
|
+
export const __wasm_bindgen_func_elem_1887: (a: number, b: number, c: number, d: number) => void;
|
|
25
|
+
export const __wasm_bindgen_func_elem_382: (a: number, b: number, c: number, d: number) => void;
|
|
27
26
|
export const __wbindgen_export: (a: number, b: number) => number;
|
|
28
27
|
export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
29
28
|
export const __wbindgen_export3: (a: number) => void;
|