@ultralytics/yolo 0.0.29 → 0.0.31
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 +12 -0
- package/dist/index.d.ts +13 -7
- package/dist/index.js +6 -2
- 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
|
@@ -145,6 +145,8 @@ Field names match the Rust/Ultralytics `Results` API 1-1:
|
|
|
145
145
|
| `probs` | `{ top1, top5, top1conf, top5conf, name, top5names, color } \| null` | classify |
|
|
146
146
|
| `masks` | `Uint8Array` (RGBA overlay, `width*height*4`) | segment, semantic |
|
|
147
147
|
| `semantic_mask` | `Uint16Array` (class id per pixel, `width*height`) | semantic |
|
|
148
|
+
| `depth` | `Uint8Array` (opaque colorized depth map, `width*height*4`) | depth |
|
|
149
|
+
| `depth_range` | `[min, max]` in meters | depth |
|
|
148
150
|
| `speed` | `{ preprocess, inference, postprocess }` ms | all |
|
|
149
151
|
|
|
150
152
|
`model.names` is the class id to name map (like `model.names` in Python). Every
|
|
@@ -152,6 +154,16 @@ detection carries its Ultralytics palette `color`, and `annotate()` draws the
|
|
|
152
154
|
`masks` overlay and the pose skeleton with the same per-limb/keypoint colors as
|
|
153
155
|
the native renderer. None of this is duplicated in JS.
|
|
154
156
|
|
|
157
|
+
For the `depth` task, `predict(img, { colormap, depthViz })` picks the colormap
|
|
158
|
+
(`"jet"` default, `"inferno"`, `"spectral"`, `"gray"`) and normalization
|
|
159
|
+
(`"disparity"` default, `"metric"`); `annotate()` blends the returned map over the
|
|
160
|
+
frame at `depthAlpha` (default `0.6`, `1` shows the raw map):
|
|
161
|
+
|
|
162
|
+
```ts
|
|
163
|
+
const results = await model.predict(img, { colormap: "spectral", depthViz: "metric" });
|
|
164
|
+
await annotate(canvas, img, results, { depthAlpha: 0.6 });
|
|
165
|
+
```
|
|
166
|
+
|
|
155
167
|
## ⚙️ Requirements & Notes
|
|
156
168
|
|
|
157
169
|
- **WebGPU** (Chrome/Edge, or Firefox with WebGPU enabled) from a **secure
|
package/dist/index.d.ts
CHANGED
|
@@ -61,9 +61,10 @@ export interface Results {
|
|
|
61
61
|
*/
|
|
62
62
|
semantic_mask?: Uint16Array;
|
|
63
63
|
/**
|
|
64
|
-
* Depth map as an opaque colorized RGBA image (`width*height*4`), using the
|
|
65
|
-
*
|
|
66
|
-
*
|
|
64
|
+
* Depth map as an opaque colorized RGBA image (`width*height*4`), using the colormap
|
|
65
|
+
* from {@link PredictOptions.colormap}; empty for other tasks. {@link annotate} blends
|
|
66
|
+
* it over the frame at {@link AnnotateOptions.depthAlpha} (default 0.6); draw it directly
|
|
67
|
+
* for the raw map.
|
|
67
68
|
*/
|
|
68
69
|
depth: Uint8Array;
|
|
69
70
|
/** Depth range `[min, max]` in meters over valid pixels, for depth models. */
|
|
@@ -115,13 +116,13 @@ export interface PredictOptions {
|
|
|
115
116
|
classes?: number[];
|
|
116
117
|
/**
|
|
117
118
|
* Depth colormap for the `depth` overlay: `"jet"` (default, classic rainbow),
|
|
118
|
-
* `"inferno"`, `"spectral"` (`Spectral_r
|
|
119
|
-
*
|
|
119
|
+
* `"inferno"`, `"spectral"` (`Spectral_r`), or `"gray"` (raw grayscale). Ignored by
|
|
120
|
+
* every other task.
|
|
120
121
|
*/
|
|
121
122
|
colormap?: "inferno" | "jet" | "spectral" | "gray";
|
|
122
123
|
/**
|
|
123
|
-
* Depth normalization: `"disparity"` (default, inverse depth + percentile clip
|
|
124
|
-
*
|
|
124
|
+
* Depth normalization: `"disparity"` (default, inverse depth + percentile clip) or
|
|
125
|
+
* `"metric"` (min/max). Ignored by every other task.
|
|
125
126
|
*/
|
|
126
127
|
depthViz?: "metric" | "disparity";
|
|
127
128
|
}
|
|
@@ -137,6 +138,11 @@ export interface AnnotateOptions {
|
|
|
137
138
|
keypoints?: boolean;
|
|
138
139
|
/** Keypoint confidence threshold for drawing. Default `0.25` (matches Ultralytics). */
|
|
139
140
|
keypointThreshold?: number;
|
|
141
|
+
/**
|
|
142
|
+
* Blend opacity for the depth overlay, `0`..`1`. Default `0.6` (matches the native
|
|
143
|
+
* annotator); `1` shows the raw colorized depth map, `0` shows only the source.
|
|
144
|
+
*/
|
|
145
|
+
depthAlpha?: number;
|
|
140
146
|
}
|
|
141
147
|
/** Image-like inputs accepted by {@link YOLO.predict}. */
|
|
142
148
|
export type ImageInput = string | URL | Blob | ArrayBuffer | Uint8Array | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap;
|
package/dist/index.js
CHANGED
|
@@ -480,13 +480,17 @@ export async function annotate(canvas, image, results, options) {
|
|
|
480
480
|
get2d(tmp).putImageData(new ImageData(new Uint8ClampedArray(overlay), width, height), 0, 0);
|
|
481
481
|
ctx.drawImage(tmp, 0, 0, width, height);
|
|
482
482
|
}
|
|
483
|
-
// Depth: the engine returns
|
|
484
|
-
//
|
|
483
|
+
// Depth: the engine returns the opaque colorized depth map, blended over the frame here
|
|
484
|
+
// at `depthAlpha` (default 0.6; pass 1 for the raw map, 0 for none). Like the segment
|
|
485
|
+
// overlay above, this assumes an opaque source (photo/camera/video frame): a source with
|
|
486
|
+
// transparent pixels keeps that transparency through the blend.
|
|
485
487
|
const depth = results.depth;
|
|
486
488
|
if (depth && depth.length === width * height * 4) {
|
|
487
489
|
const tmp = makeCanvas(width, height);
|
|
488
490
|
get2d(tmp).putImageData(new ImageData(new Uint8ClampedArray(depth), width, height), 0, 0);
|
|
491
|
+
ctx.globalAlpha = options?.depthAlpha ?? 0.6;
|
|
489
492
|
ctx.drawImage(tmp, 0, 0, width, height);
|
|
493
|
+
ctx.globalAlpha = 1;
|
|
490
494
|
}
|
|
491
495
|
const lineWidth = options?.lineWidth ?? Math.max(2, Math.round(width / 320));
|
|
492
496
|
const fontSize = Math.max(12, Math.round(width / 40));
|
package/package.json
CHANGED
package/pkg/package.json
CHANGED
|
@@ -184,10 +184,10 @@ export interface InitOutput {
|
|
|
184
184
|
readonly yolopipeline_preprocess_rgba: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
185
185
|
readonly yolopipeline_task: (a: number, b: number) => void;
|
|
186
186
|
readonly start: () => void;
|
|
187
|
-
readonly
|
|
188
|
-
readonly
|
|
189
|
-
readonly
|
|
190
|
-
readonly
|
|
187
|
+
readonly __wasm_bindgen_func_elem_1941: (a: number, b: number, c: number, d: number) => void;
|
|
188
|
+
readonly __wasm_bindgen_func_elem_2540: (a: number, b: number, c: number, d: number) => void;
|
|
189
|
+
readonly __wasm_bindgen_func_elem_1941_2: (a: number, b: number, c: number, d: number) => void;
|
|
190
|
+
readonly __wasm_bindgen_func_elem_2564: (a: number, b: number, c: number, d: number) => void;
|
|
191
191
|
readonly __wbindgen_export: (a: number, b: number) => number;
|
|
192
192
|
readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
193
193
|
readonly __wbindgen_export3: (a: number) => void;
|
|
@@ -714,7 +714,7 @@ function __wbg_get_imports() {
|
|
|
714
714
|
const a = state0.a;
|
|
715
715
|
state0.a = 0;
|
|
716
716
|
try {
|
|
717
|
-
return
|
|
717
|
+
return __wasm_bindgen_func_elem_2564(a, state0.b, arg0, arg1);
|
|
718
718
|
} finally {
|
|
719
719
|
state0.a = a;
|
|
720
720
|
}
|
|
@@ -905,17 +905,17 @@ function __wbg_get_imports() {
|
|
|
905
905
|
},
|
|
906
906
|
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
907
907
|
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 690, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
908
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
908
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_1941);
|
|
909
909
|
return addHeapObject(ret);
|
|
910
910
|
},
|
|
911
911
|
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
912
912
|
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 910, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
913
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
913
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_2540);
|
|
914
914
|
return addHeapObject(ret);
|
|
915
915
|
},
|
|
916
916
|
__wbindgen_cast_0000000000000003: function(arg0, arg1) {
|
|
917
917
|
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("boolean")], shim_idx: 690, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
918
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
918
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_1941_2);
|
|
919
919
|
return addHeapObject(ret);
|
|
920
920
|
},
|
|
921
921
|
__wbindgen_cast_0000000000000004: function(arg0) {
|
|
@@ -1002,10 +1002,10 @@ function __wbg_get_imports() {
|
|
|
1002
1002
|
};
|
|
1003
1003
|
}
|
|
1004
1004
|
|
|
1005
|
-
function
|
|
1005
|
+
function __wasm_bindgen_func_elem_1941(arg0, arg1, arg2) {
|
|
1006
1006
|
try {
|
|
1007
1007
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1008
|
-
wasm.
|
|
1008
|
+
wasm.__wasm_bindgen_func_elem_1941(retptr, arg0, arg1, addHeapObject(arg2));
|
|
1009
1009
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1010
1010
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1011
1011
|
if (r1) {
|
|
@@ -1016,10 +1016,10 @@ function __wasm_bindgen_func_elem_1945(arg0, arg1, arg2) {
|
|
|
1016
1016
|
}
|
|
1017
1017
|
}
|
|
1018
1018
|
|
|
1019
|
-
function
|
|
1019
|
+
function __wasm_bindgen_func_elem_2540(arg0, arg1, arg2) {
|
|
1020
1020
|
try {
|
|
1021
1021
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1022
|
-
wasm.
|
|
1022
|
+
wasm.__wasm_bindgen_func_elem_2540(retptr, arg0, arg1, addHeapObject(arg2));
|
|
1023
1023
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1024
1024
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1025
1025
|
if (r1) {
|
|
@@ -1030,10 +1030,10 @@ function __wasm_bindgen_func_elem_2542(arg0, arg1, arg2) {
|
|
|
1030
1030
|
}
|
|
1031
1031
|
}
|
|
1032
1032
|
|
|
1033
|
-
function
|
|
1033
|
+
function __wasm_bindgen_func_elem_1941_2(arg0, arg1, arg2) {
|
|
1034
1034
|
try {
|
|
1035
1035
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1036
|
-
wasm.
|
|
1036
|
+
wasm.__wasm_bindgen_func_elem_1941_2(retptr, arg0, arg1, addHeapObject(arg2));
|
|
1037
1037
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1038
1038
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1039
1039
|
if (r1) {
|
|
@@ -1044,8 +1044,8 @@ function __wasm_bindgen_func_elem_1945_2(arg0, arg1, arg2) {
|
|
|
1044
1044
|
}
|
|
1045
1045
|
}
|
|
1046
1046
|
|
|
1047
|
-
function
|
|
1048
|
-
wasm.
|
|
1047
|
+
function __wasm_bindgen_func_elem_2564(arg0, arg1, arg2, arg3) {
|
|
1048
|
+
wasm.__wasm_bindgen_func_elem_2564(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
|
|
1049
1049
|
}
|
|
1050
1050
|
|
|
1051
1051
|
|
|
Binary file
|
|
@@ -18,10 +18,10 @@ export const yolopipeline_postprocess: (a: number, b: number, c: number, d: numb
|
|
|
18
18
|
export const yolopipeline_preprocess_rgba: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
19
19
|
export const yolopipeline_task: (a: number, b: number) => void;
|
|
20
20
|
export const start: () => void;
|
|
21
|
-
export const
|
|
22
|
-
export const
|
|
23
|
-
export const
|
|
24
|
-
export const
|
|
21
|
+
export const __wasm_bindgen_func_elem_1941: (a: number, b: number, c: number, d: number) => void;
|
|
22
|
+
export const __wasm_bindgen_func_elem_2540: (a: number, b: number, c: number, d: number) => void;
|
|
23
|
+
export const __wasm_bindgen_func_elem_1941_2: (a: number, b: number, c: number, d: number) => void;
|
|
24
|
+
export const __wasm_bindgen_func_elem_2564: (a: number, b: number, c: number, d: number) => void;
|
|
25
25
|
export const __wbindgen_export: (a: number, b: number) => number;
|
|
26
26
|
export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
27
27
|
export const __wbindgen_export3: (a: number) => void;
|