@ultralytics/yolo 0.0.30 → 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_bg.wasm +0 -0
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
|
Binary file
|