@ultralytics/yolo 0.0.23 → 0.0.24
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 +9 -3
- package/dist/index.d.ts +4 -2
- package/dist/index.js +17 -7
- package/package.json +1 -1
- package/pkg/package.json +1 -1
- package/pkg/ultralytics_inference_web.d.ts +4 -4
- package/pkg/ultralytics_inference_web.js +12 -12
- package/pkg/ultralytics_inference_web_bg.wasm +0 -0
- package/pkg/ultralytics_inference_web_bg.wasm.d.ts +4 -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
|
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}. */
|
|
@@ -149,7 +151,7 @@ export declare class YOLO {
|
|
|
149
151
|
* Draw inference results onto a canvas, on top of the source image.
|
|
150
152
|
*
|
|
151
153
|
* Handles every task: axis-aligned boxes, oriented boxes (OBB), pose keypoints
|
|
152
|
-
* with the COCO skeleton, and a top-
|
|
154
|
+
* with the COCO skeleton, and a top-5 list for classification. The canvas is
|
|
153
155
|
* resized to the original image dimensions so detection coordinates line up.
|
|
154
156
|
*
|
|
155
157
|
* ```ts
|
package/dist/index.js
CHANGED
|
@@ -56,13 +56,13 @@ function resolveModel(src) {
|
|
|
56
56
|
return /^[\w.-]+\.onnx$/i.test(src) ? ASSETS + src : src;
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
|
-
* Reinterpret the wasm payload's little-endian `
|
|
59
|
+
* Reinterpret the wasm payload's little-endian `semantic_mask` bytes as a
|
|
60
60
|
* `Uint16Array` of class ids (a zero-copy view), leaving every other field as-is.
|
|
61
61
|
*/
|
|
62
62
|
function decodeResults(raw) {
|
|
63
63
|
const r = raw;
|
|
64
|
-
const sem = r.
|
|
65
|
-
r.
|
|
64
|
+
const sem = r.semantic_mask;
|
|
65
|
+
r.semantic_mask = sem && sem.length ? new Uint16Array(sem.buffer, sem.byteOffset, sem.length / 2) : undefined;
|
|
66
66
|
return r;
|
|
67
67
|
}
|
|
68
68
|
let initialized = false;
|
|
@@ -218,7 +218,7 @@ function textColorFor(hex) {
|
|
|
218
218
|
* Draw inference results onto a canvas, on top of the source image.
|
|
219
219
|
*
|
|
220
220
|
* Handles every task: axis-aligned boxes, oriented boxes (OBB), pose keypoints
|
|
221
|
-
* with the COCO skeleton, and a top-
|
|
221
|
+
* with the COCO skeleton, and a top-5 list for classification. The canvas is
|
|
222
222
|
* resized to the original image dimensions so detection coordinates line up.
|
|
223
223
|
*
|
|
224
224
|
* ```ts
|
|
@@ -324,9 +324,19 @@ export async function annotate(canvas, image, results, options) {
|
|
|
324
324
|
}
|
|
325
325
|
ctx.lineWidth = lineWidth;
|
|
326
326
|
}
|
|
327
|
-
// Classification: top-
|
|
328
|
-
|
|
329
|
-
|
|
327
|
+
// Classification: top-5 list on a translucent black panel (matches the native
|
|
328
|
+
// and Python renderers, which list the top classes rather than a single banner).
|
|
329
|
+
if (results.probs && showLabels) {
|
|
330
|
+
const { top5, top5conf, top5names } = results.probs;
|
|
331
|
+
const lines = top5.map((_, i) => `${top5names[i] ?? top5[i]} ${top5conf[i].toFixed(2)}`);
|
|
332
|
+
const pad = Math.round(fontSize * 0.3);
|
|
333
|
+
const lineH = Math.round(fontSize * 1.25);
|
|
334
|
+
const boxW = Math.max(...lines.map((t) => ctx.measureText(t).width)) + pad * 2;
|
|
335
|
+
const boxH = lines.length * lineH + pad * 2;
|
|
336
|
+
ctx.fillStyle = "rgba(0, 0, 0, 0.4)";
|
|
337
|
+
ctx.fillRect(pad, pad, boxW, boxH);
|
|
338
|
+
ctx.fillStyle = "#ffffff";
|
|
339
|
+
lines.forEach((t, i) => ctx.fillText(t, pad * 2, pad * 2 + i * lineH));
|
|
330
340
|
}
|
|
331
341
|
}
|
|
332
342
|
/** Resolve any {@link ImageInput} to something `drawImage` accepts. */
|
package/package.json
CHANGED
package/pkg/package.json
CHANGED
|
@@ -96,10 +96,10 @@ export interface InitOutput {
|
|
|
96
96
|
readonly yolomodel_predict_rgba: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => number;
|
|
97
97
|
readonly yolomodel_task: (a: number, b: number) => void;
|
|
98
98
|
readonly start: () => void;
|
|
99
|
-
readonly
|
|
100
|
-
readonly
|
|
101
|
-
readonly
|
|
102
|
-
readonly
|
|
99
|
+
readonly __wasm_bindgen_func_elem_1879: (a: number, b: number, c: number, d: number) => void;
|
|
100
|
+
readonly __wasm_bindgen_func_elem_2269: (a: number, b: number, c: number, d: number) => void;
|
|
101
|
+
readonly __wasm_bindgen_func_elem_1879_2: (a: number, b: number, c: number, d: number) => void;
|
|
102
|
+
readonly __wasm_bindgen_func_elem_2279: (a: number, b: number, c: number, d: number) => void;
|
|
103
103
|
readonly __wbindgen_export: (a: number, b: number) => number;
|
|
104
104
|
readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
105
105
|
readonly __wbindgen_export3: (a: number) => void;
|
|
@@ -485,7 +485,7 @@ function __wbg_get_imports() {
|
|
|
485
485
|
const a = state0.a;
|
|
486
486
|
state0.a = 0;
|
|
487
487
|
try {
|
|
488
|
-
return
|
|
488
|
+
return __wasm_bindgen_func_elem_2279(a, state0.b, arg0, arg1);
|
|
489
489
|
} finally {
|
|
490
490
|
state0.a = a;
|
|
491
491
|
}
|
|
@@ -673,17 +673,17 @@ function __wbg_get_imports() {
|
|
|
673
673
|
},
|
|
674
674
|
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
675
675
|
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 687, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
676
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
676
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_1879);
|
|
677
677
|
return addHeapObject(ret);
|
|
678
678
|
},
|
|
679
679
|
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
680
680
|
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 792, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
681
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
681
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_2269);
|
|
682
682
|
return addHeapObject(ret);
|
|
683
683
|
},
|
|
684
684
|
__wbindgen_cast_0000000000000003: function(arg0, arg1) {
|
|
685
685
|
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("boolean")], shim_idx: 687, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
686
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
686
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_1879_2);
|
|
687
687
|
return addHeapObject(ret);
|
|
688
688
|
},
|
|
689
689
|
__wbindgen_cast_0000000000000004: function(arg0) {
|
|
@@ -770,10 +770,10 @@ function __wbg_get_imports() {
|
|
|
770
770
|
};
|
|
771
771
|
}
|
|
772
772
|
|
|
773
|
-
function
|
|
773
|
+
function __wasm_bindgen_func_elem_1879(arg0, arg1, arg2) {
|
|
774
774
|
try {
|
|
775
775
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
776
|
-
wasm.
|
|
776
|
+
wasm.__wasm_bindgen_func_elem_1879(retptr, arg0, arg1, addHeapObject(arg2));
|
|
777
777
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
778
778
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
779
779
|
if (r1) {
|
|
@@ -784,10 +784,10 @@ function __wasm_bindgen_func_elem_1877(arg0, arg1, arg2) {
|
|
|
784
784
|
}
|
|
785
785
|
}
|
|
786
786
|
|
|
787
|
-
function
|
|
787
|
+
function __wasm_bindgen_func_elem_2269(arg0, arg1, arg2) {
|
|
788
788
|
try {
|
|
789
789
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
790
|
-
wasm.
|
|
790
|
+
wasm.__wasm_bindgen_func_elem_2269(retptr, arg0, arg1, addHeapObject(arg2));
|
|
791
791
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
792
792
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
793
793
|
if (r1) {
|
|
@@ -798,10 +798,10 @@ function __wasm_bindgen_func_elem_2267(arg0, arg1, arg2) {
|
|
|
798
798
|
}
|
|
799
799
|
}
|
|
800
800
|
|
|
801
|
-
function
|
|
801
|
+
function __wasm_bindgen_func_elem_1879_2(arg0, arg1, arg2) {
|
|
802
802
|
try {
|
|
803
803
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
804
|
-
wasm.
|
|
804
|
+
wasm.__wasm_bindgen_func_elem_1879_2(retptr, arg0, arg1, addHeapObject(arg2));
|
|
805
805
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
806
806
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
807
807
|
if (r1) {
|
|
@@ -812,8 +812,8 @@ function __wasm_bindgen_func_elem_1877_2(arg0, arg1, arg2) {
|
|
|
812
812
|
}
|
|
813
813
|
}
|
|
814
814
|
|
|
815
|
-
function
|
|
816
|
-
wasm.
|
|
815
|
+
function __wasm_bindgen_func_elem_2279(arg0, arg1, arg2, arg3) {
|
|
816
|
+
wasm.__wasm_bindgen_func_elem_2279(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
|
|
817
817
|
}
|
|
818
818
|
|
|
819
819
|
|
|
Binary file
|
|
@@ -10,10 +10,10 @@ export const yolomodel_predict: (a: number, b: number, c: number, d: number, e:
|
|
|
10
10
|
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
11
|
export const yolomodel_task: (a: number, b: number) => void;
|
|
12
12
|
export const start: () => void;
|
|
13
|
-
export const
|
|
14
|
-
export const
|
|
15
|
-
export const
|
|
16
|
-
export const
|
|
13
|
+
export const __wasm_bindgen_func_elem_1879: (a: number, b: number, c: number, d: number) => void;
|
|
14
|
+
export const __wasm_bindgen_func_elem_2269: (a: number, b: number, c: number, d: number) => void;
|
|
15
|
+
export const __wasm_bindgen_func_elem_1879_2: (a: number, b: number, c: number, d: number) => void;
|
|
16
|
+
export const __wasm_bindgen_func_elem_2279: (a: number, b: number, c: number, d: number) => void;
|
|
17
17
|
export const __wbindgen_export: (a: number, b: number) => number;
|
|
18
18
|
export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
19
19
|
export const __wbindgen_export3: (a: number) => void;
|