@ultralytics/yolo 0.0.49 → 0.0.51
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 +8 -8
- package/README.zh-CN.md +6 -6
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/pkg/package.json +1 -1
- package/pkg/ultralytics_inference_web.d.ts +6 -6
- package/pkg/ultralytics_inference_web.js +14 -14
- package/pkg/ultralytics_inference_web_bg.wasm +0 -0
- package/pkg/ultralytics_inference_web_bg.wasm.d.ts +4 -4
package/README.md
CHANGED
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
|
|
33
33
|
</div>
|
|
34
34
|
|
|
35
|
-
Run [Ultralytics](https://www.ultralytics.com) YOLO models directly in the browser, with no server and no Python. It runs on **WebGPU** (with an automatic CPU/wasm fallback) and covers [object detection](https://docs.ultralytics.com/tasks/detect), [instance segmentation](https://docs.ultralytics.com/tasks/segment), [
|
|
35
|
+
Run [Ultralytics](https://www.ultralytics.com) YOLO models directly in the browser, with no server and no Python. It runs on **WebGPU** (with an automatic CPU/wasm fallback) and covers [object detection](https://docs.ultralytics.com/tasks/detect), [instance segmentation](https://docs.ultralytics.com/tasks/segment), [semantic segmentation](https://docs.ultralytics.com/tasks/semantic), [depth estimation](https://docs.ultralytics.com/tasks/depth), [image classification](https://docs.ultralytics.com/tasks/classify), [pose estimation](https://docs.ultralytics.com/tasks/pose), and [oriented bounding boxes](https://docs.ultralytics.com/tasks/obb), behind a small TypeScript API with a built-in `annotate()` that draws results straight to a canvas.
|
|
36
36
|
|
|
37
37
|
```ts
|
|
38
38
|
import { YOLO, annotate } from "@ultralytics/yolo";
|
|
@@ -124,13 +124,13 @@ Runs [Ultralytics YOLOv8](https://docs.ultralytics.com/models/yolov8),
|
|
|
124
124
|
[Ultralytics YOLO26](https://docs.ultralytics.com/models/yolo26) ONNX exports for
|
|
125
125
|
[detection](https://docs.ultralytics.com/tasks/detect),
|
|
126
126
|
[segmentation](https://docs.ultralytics.com/tasks/segment),
|
|
127
|
-
[
|
|
128
|
-
[
|
|
127
|
+
[semantic segmentation](https://docs.ultralytics.com/tasks/semantic),
|
|
128
|
+
[depth estimation](https://docs.ultralytics.com/tasks/depth),
|
|
129
129
|
[classification](https://docs.ultralytics.com/tasks/classify),
|
|
130
|
-
[
|
|
131
|
-
[
|
|
130
|
+
[pose](https://docs.ultralytics.com/tasks/pose), and
|
|
131
|
+
[OBB](https://docs.ultralytics.com/tasks/obb).
|
|
132
132
|
|
|
133
|
-
`YOLO.load` takes a URL or path,
|
|
133
|
+
`YOLO.load` takes a URL or path, which the browser fetches like any other asset. Download the weights you want from the [Ultralytics assets release](https://github.com/ultralytics/assets/releases) (the same files the native crate and Python use) and host them **same-origin**, or behind a CORS-enabled origin:
|
|
134
134
|
|
|
135
135
|
```ts
|
|
136
136
|
await YOLO.load("/models/yolo26n.onnx");
|
|
@@ -141,7 +141,7 @@ GitHub release assets send no `Access-Control-Allow-Origin`, so a browser cannot
|
|
|
141
141
|
## 📐 Results Shape
|
|
142
142
|
|
|
143
143
|
`predict()` resolves to a `Results` object whose field names match the
|
|
144
|
-
Rust/Ultralytics `Results` API
|
|
144
|
+
Rust/Ultralytics `Results` API one-to-one:
|
|
145
145
|
|
|
146
146
|
| Field | Type | Tasks |
|
|
147
147
|
| ------------------ | -------------------------------------------------------------------- | --------------------- |
|
|
@@ -299,7 +299,7 @@ Notes:
|
|
|
299
299
|
If you load an NMS-free `.tflite`, the backend auto-switches it to wasm
|
|
300
300
|
(slower) and logs a warning rather than returning empty results.
|
|
301
301
|
|
|
302
|
-
- **Tasks**: detect, segment,
|
|
302
|
+
- **Tasks**: detect, segment, semantic, depth, classify, pose, and obb are all supported.
|
|
303
303
|
- **Cross-origin isolation**: LiteRT's threaded wasm wants `SharedArrayBuffer`,
|
|
304
304
|
so serve with `Cross-Origin-Opener-Policy: same-origin` and
|
|
305
305
|
`Cross-Origin-Embedder-Policy: require-corp`.
|
package/README.zh-CN.md
CHANGED
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
|
|
33
33
|
</div>
|
|
34
34
|
|
|
35
|
-
直接在浏览器中运行 [Ultralytics](https://www.ultralytics.com) YOLO 模型,无需服务器,也无需 Python。本库基于 **WebGPU**(并自动回退到 CPU/wasm),支持[目标检测](https://docs.ultralytics.com/tasks/detect)、[实例分割](https://docs.ultralytics.com/tasks/segment)、[
|
|
35
|
+
直接在浏览器中运行 [Ultralytics](https://www.ultralytics.com) YOLO 模型,无需服务器,也无需 Python。本库基于 **WebGPU**(并自动回退到 CPU/wasm),支持[目标检测](https://docs.ultralytics.com/tasks/detect)、[实例分割](https://docs.ultralytics.com/tasks/segment)、[语义分割](https://docs.ultralytics.com/tasks/semantic)、[深度估计](https://docs.ultralytics.com/tasks/depth)、[图像分类](https://docs.ultralytics.com/tasks/classify)、[姿态估计](https://docs.ultralytics.com/tasks/pose)和[旋转边界框](https://docs.ultralytics.com/tasks/obb),接口是一个小巧的 TypeScript API,内置的 `annotate()` 可直接把结果绘制到 canvas 上。
|
|
36
36
|
|
|
37
37
|
```ts
|
|
38
38
|
import { YOLO, annotate } from "@ultralytics/yolo";
|
|
@@ -120,11 +120,11 @@ async function frame() {
|
|
|
120
120
|
[Ultralytics YOLO26](https://docs.ultralytics.com/models/yolo26) 的 ONNX 导出模型,覆盖
|
|
121
121
|
[检测](https://docs.ultralytics.com/tasks/detect)、
|
|
122
122
|
[分割](https://docs.ultralytics.com/tasks/segment)、
|
|
123
|
-
[
|
|
124
|
-
[
|
|
123
|
+
[语义分割](https://docs.ultralytics.com/tasks/semantic)、
|
|
124
|
+
[深度估计](https://docs.ultralytics.com/tasks/depth)、
|
|
125
125
|
[分类](https://docs.ultralytics.com/tasks/classify)、
|
|
126
|
-
[
|
|
127
|
-
[
|
|
126
|
+
[姿态](https://docs.ultralytics.com/tasks/pose)和
|
|
127
|
+
[OBB](https://docs.ultralytics.com/tasks/obb)。
|
|
128
128
|
|
|
129
129
|
`YOLO.load` 接受 URL 或路径,浏览器会像加载其他静态资源一样获取它。请从 [Ultralytics assets release](https://github.com/ultralytics/assets/releases) 下载所需权重(与原生 crate 和 Python 使用的是同一份文件),并部署在**同源**位置,或放在启用了 CORS 的源之后:
|
|
130
130
|
|
|
@@ -275,7 +275,7 @@ wasm 默认从 jsDelivr CDN 加载;向 `YOLO.load` 传入 `litertWasmUrl: "/li
|
|
|
275
275
|
|
|
276
276
|
如果加载了无 NMS 的 `.tflite`,后端会自动切换到 wasm(较慢)并打印警告,而不是返回空结果。
|
|
277
277
|
|
|
278
|
-
- **支持的任务**:detect、segment、
|
|
278
|
+
- **支持的任务**:detect、segment、semantic、depth、classify、pose 和 obb 均已支持。
|
|
279
279
|
- **跨源隔离**:LiteRT 的多线程 wasm 需要 `SharedArrayBuffer`,因此请以
|
|
280
280
|
`Cross-Origin-Opener-Policy: same-origin` 和 `Cross-Origin-Embedder-Policy: require-corp`
|
|
281
281
|
提供服务。
|
package/dist/index.d.ts
CHANGED
|
@@ -172,7 +172,7 @@ export declare class YOLO {
|
|
|
172
172
|
/** Load the LiteRT (`.tflite`) backend. Metadata (task, class names, `imgsz`)
|
|
173
173
|
* is read from the single `.tflite` file, the same as the `.onnx` path. */
|
|
174
174
|
private static loadLiteRt;
|
|
175
|
-
/** The model's task (`detect`, `segment`, `
|
|
175
|
+
/** The model's task (`detect`, `segment`, `semantic`, `depth`, `classify`, `pose`, `obb`). */
|
|
176
176
|
get task(): string;
|
|
177
177
|
/** The active device that ran inference (`"webgpu"` or `"cpu"`). */
|
|
178
178
|
get device(): string;
|
package/dist/index.js
CHANGED
|
@@ -412,7 +412,7 @@ export class YOLO {
|
|
|
412
412
|
pipeline.setInputShape(new Int32Array(shape));
|
|
413
413
|
return new YOLO(new LiteRtEngine(pipeline, backend));
|
|
414
414
|
}
|
|
415
|
-
/** The model's task (`detect`, `segment`, `
|
|
415
|
+
/** The model's task (`detect`, `segment`, `semantic`, `depth`, `classify`, `pose`, `obb`). */
|
|
416
416
|
get task() {
|
|
417
417
|
return this.engine.task;
|
|
418
418
|
}
|
package/package.json
CHANGED
package/pkg/package.json
CHANGED
|
@@ -65,8 +65,8 @@ export class YoloModel {
|
|
|
65
65
|
*/
|
|
66
66
|
readonly names: any;
|
|
67
67
|
/**
|
|
68
|
-
* The model's task (`"detect"`, `"segment"`, `"
|
|
69
|
-
* `"
|
|
68
|
+
* The model's task (`"detect"`, `"segment"`, `"semantic"`, `"depth"`,
|
|
69
|
+
* `"classify"`, `"pose"`, or `"obb"`).
|
|
70
70
|
*/
|
|
71
71
|
readonly task: string;
|
|
72
72
|
}
|
|
@@ -207,10 +207,10 @@ export interface InitOutput {
|
|
|
207
207
|
readonly yolopipeline_rtdetr: (a: number) => number;
|
|
208
208
|
readonly yolopipeline_setInputShape: (a: number, b: number, c: number) => void;
|
|
209
209
|
readonly yolopipeline_task: (a: number, b: number) => void;
|
|
210
|
-
readonly
|
|
211
|
-
readonly
|
|
212
|
-
readonly
|
|
213
|
-
readonly
|
|
210
|
+
readonly __wasm_bindgen_func_elem_2005: (a: number, b: number, c: number, d: number) => void;
|
|
211
|
+
readonly __wasm_bindgen_func_elem_2005_20: (a: number, b: number, c: number, d: number) => void;
|
|
212
|
+
readonly __wasm_bindgen_func_elem_2611: (a: number, b: number, c: number, d: number) => void;
|
|
213
|
+
readonly __wasm_bindgen_func_elem_2635: (a: number, b: number, c: number, d: number) => void;
|
|
214
214
|
readonly __wbindgen_export: (a: number, b: number) => number;
|
|
215
215
|
readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
216
216
|
readonly __wbindgen_export3: (a: number) => void;
|
|
@@ -162,8 +162,8 @@ export class YoloModel {
|
|
|
162
162
|
return takeObject(ret);
|
|
163
163
|
}
|
|
164
164
|
/**
|
|
165
|
-
* The model's task (`"detect"`, `"segment"`, `"
|
|
166
|
-
* `"
|
|
165
|
+
* The model's task (`"detect"`, `"segment"`, `"semantic"`, `"depth"`,
|
|
166
|
+
* `"classify"`, `"pose"`, or `"obb"`).
|
|
167
167
|
* @returns {string}
|
|
168
168
|
*/
|
|
169
169
|
get task() {
|
|
@@ -744,7 +744,7 @@ function __wbg_get_imports() {
|
|
|
744
744
|
const a = state0.a;
|
|
745
745
|
state0.a = 0;
|
|
746
746
|
try {
|
|
747
|
-
return
|
|
747
|
+
return __wasm_bindgen_func_elem_2635(a, state0.b, arg0, arg1);
|
|
748
748
|
} finally {
|
|
749
749
|
state0.a = a;
|
|
750
750
|
}
|
|
@@ -935,17 +935,17 @@ function __wbg_get_imports() {
|
|
|
935
935
|
},
|
|
936
936
|
__wbindgen_generic_0000000000000001: function(arg0, arg1) {
|
|
937
937
|
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 693, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
938
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
938
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_2005);
|
|
939
939
|
return addHeapObject(ret);
|
|
940
940
|
},
|
|
941
941
|
__wbindgen_generic_0000000000000002: function(arg0, arg1) {
|
|
942
942
|
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 921, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
943
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
943
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_2611);
|
|
944
944
|
return addHeapObject(ret);
|
|
945
945
|
},
|
|
946
946
|
__wbindgen_generic_0000000000000003: function(arg0, arg1) {
|
|
947
947
|
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("boolean")], shim_idx: 693, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
948
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
948
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_2005_20);
|
|
949
949
|
return addHeapObject(ret);
|
|
950
950
|
},
|
|
951
951
|
__wbindgen_generic_0000000000000004: function(arg0) {
|
|
@@ -1032,14 +1032,14 @@ function __wbg_get_imports() {
|
|
|
1032
1032
|
};
|
|
1033
1033
|
}
|
|
1034
1034
|
|
|
1035
|
-
function
|
|
1036
|
-
wasm.
|
|
1035
|
+
function __wasm_bindgen_func_elem_2635(arg0, arg1, arg2, arg3) {
|
|
1036
|
+
wasm.__wasm_bindgen_func_elem_2635(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
|
|
1037
1037
|
}
|
|
1038
1038
|
|
|
1039
|
-
function
|
|
1039
|
+
function __wasm_bindgen_func_elem_2005(arg0, arg1, arg2) {
|
|
1040
1040
|
try {
|
|
1041
1041
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1042
|
-
wasm.
|
|
1042
|
+
wasm.__wasm_bindgen_func_elem_2005(retptr, arg0, arg1, addHeapObject(arg2));
|
|
1043
1043
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1044
1044
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1045
1045
|
if (r1) {
|
|
@@ -1050,10 +1050,10 @@ function __wasm_bindgen_func_elem_1997(arg0, arg1, arg2) {
|
|
|
1050
1050
|
}
|
|
1051
1051
|
}
|
|
1052
1052
|
|
|
1053
|
-
function
|
|
1053
|
+
function __wasm_bindgen_func_elem_2611(arg0, arg1, arg2) {
|
|
1054
1054
|
try {
|
|
1055
1055
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1056
|
-
wasm.
|
|
1056
|
+
wasm.__wasm_bindgen_func_elem_2611(retptr, arg0, arg1, addHeapObject(arg2));
|
|
1057
1057
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1058
1058
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1059
1059
|
if (r1) {
|
|
@@ -1064,10 +1064,10 @@ function __wasm_bindgen_func_elem_2604(arg0, arg1, arg2) {
|
|
|
1064
1064
|
}
|
|
1065
1065
|
}
|
|
1066
1066
|
|
|
1067
|
-
function
|
|
1067
|
+
function __wasm_bindgen_func_elem_2005_20(arg0, arg1, arg2) {
|
|
1068
1068
|
try {
|
|
1069
1069
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1070
|
-
wasm.
|
|
1070
|
+
wasm.__wasm_bindgen_func_elem_2005_20(retptr, arg0, arg1, addHeapObject(arg2));
|
|
1071
1071
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1072
1072
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1073
1073
|
if (r1) {
|
|
Binary file
|
|
@@ -20,10 +20,10 @@ export const yolopipeline_preprocess_rgba: (a: number, b: number, c: number, d:
|
|
|
20
20
|
export const yolopipeline_rtdetr: (a: number) => number;
|
|
21
21
|
export const yolopipeline_setInputShape: (a: number, b: number, c: number) => void;
|
|
22
22
|
export const yolopipeline_task: (a: number, b: number) => void;
|
|
23
|
-
export const
|
|
24
|
-
export const
|
|
25
|
-
export const
|
|
26
|
-
export const
|
|
23
|
+
export const __wasm_bindgen_func_elem_2005: (a: number, b: number, c: number, d: number) => void;
|
|
24
|
+
export const __wasm_bindgen_func_elem_2005_20: (a: number, b: number, c: number, d: number) => void;
|
|
25
|
+
export const __wasm_bindgen_func_elem_2611: (a: number, b: number, c: number, d: number) => void;
|
|
26
|
+
export const __wasm_bindgen_func_elem_2635: (a: number, b: number, c: number, d: number) => void;
|
|
27
27
|
export const __wbindgen_export: (a: number, b: number) => number;
|
|
28
28
|
export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
29
29
|
export const __wbindgen_export3: (a: number) => void;
|