@mauriciobenjamin700/ort-vision-sdk-web 0.7.0 → 0.8.0
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/CHANGELOG.md +121 -1
- package/dist/core/providers.d.ts +31 -0
- package/dist/core/providers.d.ts.map +1 -1
- package/dist/core/providers.js +64 -0
- package/dist/core/providers.js.map +1 -1
- package/dist/core/session.d.ts +30 -1
- package/dist/core/session.d.ts.map +1 -1
- package/dist/core/session.js +56 -4
- package/dist/core/session.js.map +1 -1
- package/dist/fusion.d.ts +8 -1
- package/dist/fusion.d.ts.map +1 -1
- package/dist/fusion.js +8 -1
- package/dist/fusion.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/normalization.d.ts +84 -0
- package/dist/normalization.d.ts.map +1 -0
- package/dist/normalization.js +99 -0
- package/dist/normalization.js.map +1 -0
- package/dist/preprocess/pipeline.d.ts +6 -3
- package/dist/preprocess/pipeline.d.ts.map +1 -1
- package/dist/preprocess/pipeline.js +61 -13
- package/dist/preprocess/pipeline.js.map +1 -1
- package/dist/tasks/classifier.d.ts +47 -6
- package/dist/tasks/classifier.d.ts.map +1 -1
- package/dist/tasks/classifier.js +41 -5
- package/dist/tasks/classifier.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,124 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.8.0] - 2026-09-04
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- **`Classifier` no longer applies a second softmax to a probability vector.**
|
|
15
|
+
`applySoftmax` defaulted to `true`, but every Ultralytics classification export
|
|
16
|
+
ends in a `Softmax` node, so the task was softmaxing an already-normalized
|
|
17
|
+
vector. It is monotonic, which is why it survived: top-1 is unchanged and every
|
|
18
|
+
confidence attached to it is wrong. Measured in the Python SDK against
|
|
19
|
+
Ultralytics' own pipeline over the same file, the maximum absolute probability
|
|
20
|
+
error went from `7.6e-07` to `0.82`.
|
|
21
|
+
|
|
22
|
+
It now defaults to undefined, which reads the model's metadata and answers
|
|
23
|
+
`false` for that family; passing a boolean still overrides.
|
|
24
|
+
`classifier.appliesSoftmax` reports the choice.
|
|
25
|
+
|
|
26
|
+
- **`Classifier` picks its normalization from the model.** The default was the
|
|
27
|
+
ImageNet mean and deviation for everybody, which is right for a
|
|
28
|
+
torchvision-style model and wrong for an Ultralytics one — its classification
|
|
29
|
+
head consumes raw `[0, 1]`. Loading a `YOLO(...).export(format="onnx")`
|
|
30
|
+
classifier with the old default fed it a tensor it never saw in training, and
|
|
31
|
+
nothing said so: no exception, no warning, a prediction of exactly the right
|
|
32
|
+
shape that is simply worse.
|
|
33
|
+
|
|
34
|
+
The answer was already in the file — every Ultralytics export stamps
|
|
35
|
+
`author: Ultralytics` and `task: classify` into its metadata, the same block
|
|
36
|
+
the class names already came from. The new `normalization` option defaults to
|
|
37
|
+
`"auto"`, which reads it and picks: `"ultralytics"` (identity) for that export,
|
|
38
|
+
`"imagenet"` for anything else. `"imagenet"`, `"ultralytics"` and `"none"` name
|
|
39
|
+
the presets explicitly, `mean`/`std` still override, and passing both throws
|
|
40
|
+
`RangeError` rather than silently preferring one. Supplying only one of
|
|
41
|
+
`mean`/`std` now leaves the other at the preset value.
|
|
42
|
+
`classifier.normalization` reports what is in effect.
|
|
43
|
+
|
|
44
|
+
**This changes what an Ultralytics classifier is fed when loaded with the
|
|
45
|
+
defaults.** Those models were being run degraded, so the change corrects them
|
|
46
|
+
rather than breaking them.
|
|
47
|
+
|
|
48
|
+
Mirrors the same change in `ort-vision-sdk` 0.9.0 (Python), including the
|
|
49
|
+
build-time `fuse_detect_classify`.
|
|
50
|
+
|
|
51
|
+
### Fixed
|
|
52
|
+
|
|
53
|
+
- **A session asking only for `webgpu` on a device without it now runs, instead
|
|
54
|
+
of failing to load.** Capability detection can rule out every requested
|
|
55
|
+
provider, and handing ORT the unsatisfiable list makes `InferenceSession.create`
|
|
56
|
+
reject with `no available backend found` — the page gets no inference at all
|
|
57
|
+
rather than the slow-but-working fallback. The effective list now floors at
|
|
58
|
+
`wasm`, which ORT-Web can always run, and the warning names it instead of
|
|
59
|
+
claiming the session will run on `[]`. Found in a real Chromium, where
|
|
60
|
+
`navigator.gpu` exists but yields no adapter; no amount of stubbed
|
|
61
|
+
`navigator` in the unit tests reproduced it.
|
|
62
|
+
|
|
63
|
+
- **`OrtSession.providers` no longer names a provider this browser cannot run.**
|
|
64
|
+
It held the result of `resolveProviders(...)` — the list that was *asked for* —
|
|
65
|
+
and ORT-Web falls back in silence, so a page requesting `webgpu` on a device
|
|
66
|
+
without it ran on WASM several times slower with nothing in the console.
|
|
67
|
+
|
|
68
|
+
ORT-Web exposes no equivalent of Node's `getProviders()`, so the effective
|
|
69
|
+
provider cannot be read back. What the browser does answer is whether the
|
|
70
|
+
underlying API exists at all, and the new `detectProviders` uses that:
|
|
71
|
+
`webgpu` survives only where `navigator.gpu` returns an adapter, `webnn` only
|
|
72
|
+
where `navigator.ml` exists, and anything untestable is kept rather than
|
|
73
|
+
guessed away. `providers` now reports that narrowed list — best-effort, so an
|
|
74
|
+
entry means "not ruled out", not "confirmed" — and the requested list is
|
|
75
|
+
preserved as the new `requestedProviders`. Naming a provider explicitly and
|
|
76
|
+
not getting it emits a `console.warn`; the default list falling back stays
|
|
77
|
+
quiet, which is what it is for.
|
|
78
|
+
|
|
79
|
+
Mirrors the same fix in `ort-vision-sdk` 0.9.0 (Python), where ORT does report
|
|
80
|
+
the effective list and it is read back directly.
|
|
81
|
+
|
|
82
|
+
- **The changelog's link table is no longer stuck at 0.7.0.** `[Unreleased]`
|
|
83
|
+
compared against `web-v0.7.0`, so the shipped 0.7.1 read as unreleased work,
|
|
84
|
+
and `[0.7.1]` had no link definition at all — it rendered as literal text.
|
|
85
|
+
|
|
86
|
+
### Documentation
|
|
87
|
+
|
|
88
|
+
- **`OUTPUT_BOXES` states which box a fused pipeline reports.** A file fused by
|
|
89
|
+
`ort-vision-sdk` 0.9.0 or later reports the box that was actually classified,
|
|
90
|
+
clamped to the image the crop came from; older files report the raw box, which
|
|
91
|
+
draws a rectangle wider than the region the classifier saw. No runtime change
|
|
92
|
+
on this side — the semantics live in the graph — but consumers drawing that
|
|
93
|
+
rectangle need to know which file they have.
|
|
94
|
+
|
|
95
|
+
## [0.7.1] - 2026-08-14
|
|
96
|
+
|
|
97
|
+
### Fixed
|
|
98
|
+
|
|
99
|
+
- **A pipeline buffer that a consumer transferred away is replaced instead of
|
|
100
|
+
written into.** `LetterboxPipeline` and `ResizePipeline` hold one
|
|
101
|
+
`Float32Array` and hand the same one out every call, which is the whole point
|
|
102
|
+
of them — but `ort.env.wasm.proxy` (ONNX Runtime in a worker) posts the input
|
|
103
|
+
tensors with their `ArrayBuffer`s in the transfer list, and that **detaches**
|
|
104
|
+
them on this side. A detached `Float32Array` is silently `0` long: the writes
|
|
105
|
+
land nowhere and the next `InferenceSession.run` rejects with
|
|
106
|
+
|
|
107
|
+
```text
|
|
108
|
+
Tensor's size(1228800) does not match data length(0).
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
on every other call — the detached buffer throws, the throw leaves the claim
|
|
112
|
+
outstanding, so the call after it allocates a fresh array and succeeds.
|
|
113
|
+
Measured in Chromium against a 640×640 YOLO detector: run 1 ok (195 ms), run 2
|
|
114
|
+
rejected, run 3 ok (206 ms).
|
|
115
|
+
|
|
116
|
+
The buffer holder now treats a length that no longer matches the target as
|
|
117
|
+
spent and allocates a replacement, so the cost is one allocation per transfer
|
|
118
|
+
instead of a failure every second inference — and reuse still holds for every
|
|
119
|
+
consumer that copies the tensor rather than transferring it. Nothing about the
|
|
120
|
+
public shape changed: `run()` still reports `reused: true` when the returned
|
|
121
|
+
data is the pipeline's own buffer.
|
|
122
|
+
|
|
123
|
+
Without this, `env.wasm.proxy` is unusable with the built-in tasks, and that
|
|
124
|
+
flag is the only way to keep inference off the browser's main thread — measured
|
|
125
|
+
at 805 ms of frozen UI for one warm-up on a 32-core desktop, against 18 ms with
|
|
126
|
+
the worker.
|
|
127
|
+
|
|
10
128
|
## [0.7.0] - 2026-08-08
|
|
11
129
|
|
|
12
130
|
### Added
|
|
@@ -502,7 +620,9 @@ console.log(r.boxes.xyxy, r.boxes.cls, r.boxes.conf, r.names);
|
|
|
502
620
|
- Execution-provider resolution defaulting to `["webgpu", "wasm"]`.
|
|
503
621
|
- Public types mirroring the Python SDK: `BoundingBox`, `ClassProbability`, `ClassificationResult`, `DetectionResult`, `RGBImage`.
|
|
504
622
|
|
|
505
|
-
[Unreleased]: https://github.com/mauriciobenjamin700/ort-vision-sdk/compare/web-v0.
|
|
623
|
+
[Unreleased]: https://github.com/mauriciobenjamin700/ort-vision-sdk/compare/web-v0.8.0...HEAD
|
|
624
|
+
[0.8.0]: https://github.com/mauriciobenjamin700/ort-vision-sdk/compare/web-v0.7.1...web-v0.8.0
|
|
625
|
+
[0.7.1]: https://github.com/mauriciobenjamin700/ort-vision-sdk/compare/web-v0.7.0...web-v0.7.1
|
|
506
626
|
[0.7.0]: https://github.com/mauriciobenjamin700/ort-vision-sdk/compare/web-v0.6.1...web-v0.7.0
|
|
507
627
|
[0.6.1]: https://github.com/mauriciobenjamin700/ort-vision-sdk/compare/web-v0.6.0...web-v0.6.1
|
|
508
628
|
[0.6.0]: https://github.com/mauriciobenjamin700/ort-vision-sdk/compare/web-v0.5.1...web-v0.6.0
|
package/dist/core/providers.d.ts
CHANGED
|
@@ -12,10 +12,41 @@
|
|
|
12
12
|
* automatically when WebGPU is not supported by the browser or device.
|
|
13
13
|
*/
|
|
14
14
|
export declare const DEFAULT_PROVIDERS: readonly string[];
|
|
15
|
+
/**
|
|
16
|
+
* The provider ORT-Web can always run, whatever the device.
|
|
17
|
+
*
|
|
18
|
+
* Used as the floor when capability detection rules everything else out. Passing
|
|
19
|
+
* ORT a list it cannot satisfy is not a graceful failure — `InferenceSession.create`
|
|
20
|
+
* rejects with "no available backend found" and the page gets no inference at
|
|
21
|
+
* all, which is worse than the slow-but-working fallback the warning describes.
|
|
22
|
+
*/
|
|
23
|
+
export declare const FALLBACK_PROVIDER = "wasm";
|
|
15
24
|
/**
|
|
16
25
|
* Resolve the execution providers to pass to `InferenceSession.create`.
|
|
17
26
|
*
|
|
18
27
|
* @param requested Explicit provider list in preference order; `undefined` returns the default.
|
|
19
28
|
*/
|
|
20
29
|
export declare function resolveProviders(requested?: readonly string[]): string[];
|
|
30
|
+
/**
|
|
31
|
+
* Narrow a provider list to the ones this browser can actually offer.
|
|
32
|
+
*
|
|
33
|
+
* ORT-Web exposes no equivalent of Node's `session.getProviders()`, so there is
|
|
34
|
+
* no way to ask which provider a session ended up on. What the browser *does*
|
|
35
|
+
* answer is whether the underlying API exists at all — no `navigator.gpu`, or no
|
|
36
|
+
* adapter behind it, means `webgpu` was never going to run — and that covers the
|
|
37
|
+
* case that actually bites: a page asking for WebGPU on a device without it,
|
|
38
|
+
* silently getting WASM, and being several times slower than intended with no
|
|
39
|
+
* error to point at.
|
|
40
|
+
*
|
|
41
|
+
* This is best-effort by construction. A provider that survives here can still
|
|
42
|
+
* fail inside ORT for a reason the browser does not surface (a missing shader
|
|
43
|
+
* feature, an exhausted device), so a surviving entry means "not ruled out",
|
|
44
|
+
* not "confirmed running". Anything this function does not know how to test is
|
|
45
|
+
* kept rather than dropped: guessing a provider away would be worse than
|
|
46
|
+
* admitting ignorance about it.
|
|
47
|
+
*
|
|
48
|
+
* @param requested Providers in preference order, already resolved.
|
|
49
|
+
* @returns The subset that is not ruled out, in the same order.
|
|
50
|
+
*/
|
|
51
|
+
export declare function detectProviders(requested: readonly string[]): Promise<string[]>;
|
|
21
52
|
//# sourceMappingURL=providers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../src/core/providers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,EAAE,SAAS,MAAM,EAAuB,CAAC;AAEvE;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,EAAE,CAQxE"}
|
|
1
|
+
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../src/core/providers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,EAAE,SAAS,MAAM,EAAuB,CAAC;AAEvE;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,SAAS,CAAC;AAExC;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,EAAE,CAQxE;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,eAAe,CACnC,SAAS,EAAE,SAAS,MAAM,EAAE,GAC3B,OAAO,CAAC,MAAM,EAAE,CAAC,CAYnB"}
|
package/dist/core/providers.js
CHANGED
|
@@ -12,6 +12,15 @@
|
|
|
12
12
|
* automatically when WebGPU is not supported by the browser or device.
|
|
13
13
|
*/
|
|
14
14
|
export const DEFAULT_PROVIDERS = ["webgpu", "wasm"];
|
|
15
|
+
/**
|
|
16
|
+
* The provider ORT-Web can always run, whatever the device.
|
|
17
|
+
*
|
|
18
|
+
* Used as the floor when capability detection rules everything else out. Passing
|
|
19
|
+
* ORT a list it cannot satisfy is not a graceful failure — `InferenceSession.create`
|
|
20
|
+
* rejects with "no available backend found" and the page gets no inference at
|
|
21
|
+
* all, which is worse than the slow-but-working fallback the warning describes.
|
|
22
|
+
*/
|
|
23
|
+
export const FALLBACK_PROVIDER = "wasm";
|
|
15
24
|
/**
|
|
16
25
|
* Resolve the execution providers to pass to `InferenceSession.create`.
|
|
17
26
|
*
|
|
@@ -26,4 +35,59 @@ export function resolveProviders(requested) {
|
|
|
26
35
|
}
|
|
27
36
|
return [...requested];
|
|
28
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Narrow a provider list to the ones this browser can actually offer.
|
|
40
|
+
*
|
|
41
|
+
* ORT-Web exposes no equivalent of Node's `session.getProviders()`, so there is
|
|
42
|
+
* no way to ask which provider a session ended up on. What the browser *does*
|
|
43
|
+
* answer is whether the underlying API exists at all — no `navigator.gpu`, or no
|
|
44
|
+
* adapter behind it, means `webgpu` was never going to run — and that covers the
|
|
45
|
+
* case that actually bites: a page asking for WebGPU on a device without it,
|
|
46
|
+
* silently getting WASM, and being several times slower than intended with no
|
|
47
|
+
* error to point at.
|
|
48
|
+
*
|
|
49
|
+
* This is best-effort by construction. A provider that survives here can still
|
|
50
|
+
* fail inside ORT for a reason the browser does not surface (a missing shader
|
|
51
|
+
* feature, an exhausted device), so a surviving entry means "not ruled out",
|
|
52
|
+
* not "confirmed running". Anything this function does not know how to test is
|
|
53
|
+
* kept rather than dropped: guessing a provider away would be worse than
|
|
54
|
+
* admitting ignorance about it.
|
|
55
|
+
*
|
|
56
|
+
* @param requested Providers in preference order, already resolved.
|
|
57
|
+
* @returns The subset that is not ruled out, in the same order.
|
|
58
|
+
*/
|
|
59
|
+
export async function detectProviders(requested) {
|
|
60
|
+
const webgpu = await hasWebGpuAdapter();
|
|
61
|
+
return requested.filter((provider) => {
|
|
62
|
+
switch (provider) {
|
|
63
|
+
case "webgpu":
|
|
64
|
+
return webgpu;
|
|
65
|
+
case "webnn":
|
|
66
|
+
return typeof navigator !== "undefined" && "ml" in navigator;
|
|
67
|
+
default:
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Whether this environment exposes a WebGPU adapter.
|
|
74
|
+
*
|
|
75
|
+
* `navigator.gpu` existing is not enough — a browser can ship the API and still
|
|
76
|
+
* hand back no adapter (a blocklisted driver, a headless context, a machine with
|
|
77
|
+
* no suitable GPU), which is exactly the configuration where a page asks for
|
|
78
|
+
* WebGPU and quietly runs on WASM.
|
|
79
|
+
*/
|
|
80
|
+
async function hasWebGpuAdapter() {
|
|
81
|
+
const gpu = globalThis.navigator
|
|
82
|
+
?.gpu;
|
|
83
|
+
if (gpu === undefined) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
try {
|
|
87
|
+
return (await gpu.requestAdapter()) !== null;
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
29
93
|
//# sourceMappingURL=providers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providers.js","sourceRoot":"","sources":["../../src/core/providers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAsB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;AAEvE;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,SAA6B;IAC5D,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC5B,OAAO,CAAC,GAAG,iBAAiB,CAAC,CAAC;IAChC,CAAC;IACD,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3B,OAAO,CAAC,GAAG,iBAAiB,CAAC,CAAC;IAChC,CAAC;IACD,OAAO,CAAC,GAAG,SAAS,CAAC,CAAC;AACxB,CAAC"}
|
|
1
|
+
{"version":3,"file":"providers.js","sourceRoot":"","sources":["../../src/core/providers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAsB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;AAEvE;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC;AAExC;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,SAA6B;IAC5D,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC5B,OAAO,CAAC,GAAG,iBAAiB,CAAC,CAAC;IAChC,CAAC;IACD,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3B,OAAO,CAAC,GAAG,iBAAiB,CAAC,CAAC;IAChC,CAAC;IACD,OAAO,CAAC,GAAG,SAAS,CAAC,CAAC;AACxB,CAAC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,SAA4B;IAE5B,MAAM,MAAM,GAAG,MAAM,gBAAgB,EAAE,CAAC;IACxC,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE;QACnC,QAAQ,QAAQ,EAAE,CAAC;YACjB,KAAK,QAAQ;gBACX,OAAO,MAAM,CAAC;YAChB,KAAK,OAAO;gBACV,OAAO,OAAO,SAAS,KAAK,WAAW,IAAI,IAAI,IAAI,SAAS,CAAC;YAC/D;gBACE,OAAO,IAAI,CAAC;QAChB,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;GAOG;AACH,KAAK,UAAU,gBAAgB;IAC7B,MAAM,GAAG,GAAI,UAAU,CAAC,SAA0E;QAChG,EAAE,GAAG,CAAC;IACR,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACtB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,CAAC;QACH,OAAO,CAAC,MAAM,GAAG,CAAC,cAAc,EAAE,CAAC,KAAK,IAAI,CAAC;IAC/C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
package/dist/core/session.d.ts
CHANGED
|
@@ -6,7 +6,12 @@ import { type DeclaredShape } from "./graph.js";
|
|
|
6
6
|
/** Anything `InferenceSession.create` accepts. */
|
|
7
7
|
export type ModelSource = string | ArrayBufferLike | Uint8Array;
|
|
8
8
|
export interface OrtSessionOptions {
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* Execution providers in preference order. `undefined` uses {@link DEFAULT_PROVIDERS}.
|
|
11
|
+
*
|
|
12
|
+
* Naming one explicitly also opts into a `console.warn` when this browser
|
|
13
|
+
* cannot offer it, instead of falling back in silence.
|
|
14
|
+
*/
|
|
10
15
|
readonly providers?: readonly string[];
|
|
11
16
|
/** Optional ORT session options forwarded to `InferenceSession.create`. */
|
|
12
17
|
readonly sessionOptions?: ort.InferenceSession.SessionOptions;
|
|
@@ -38,8 +43,32 @@ export interface OrtSessionOptions {
|
|
|
38
43
|
*/
|
|
39
44
|
export declare class OrtSession {
|
|
40
45
|
private readonly _session;
|
|
46
|
+
/**
|
|
47
|
+
* Execution providers this session is expected to run on.
|
|
48
|
+
*
|
|
49
|
+
* The requested list narrowed to what this browser can actually offer — a
|
|
50
|
+
* `webgpu` entry survives only where an adapter exists. Best-effort: ORT-Web
|
|
51
|
+
* exposes no way to ask which provider a session ended up on, so an entry
|
|
52
|
+
* here means "not ruled out", not "confirmed". See
|
|
53
|
+
* {@link requestedProviders} for what was asked for.
|
|
54
|
+
*
|
|
55
|
+
* When nothing survives — a caller asking for `webgpu` alone on a device
|
|
56
|
+
* without it — this falls back to {@link FALLBACK_PROVIDER}, which ORT-Web
|
|
57
|
+
* can always run. Handing ORT the unsatisfiable list instead makes
|
|
58
|
+
* `InferenceSession.create` reject with "no available backend found", so the
|
|
59
|
+
* page gets no inference at all rather than the slow-but-working fallback
|
|
60
|
+
* the `console.warn` describes. Measured in a real Chromium, where
|
|
61
|
+
* `navigator.gpu` exists but yields no adapter.
|
|
62
|
+
*/
|
|
41
63
|
readonly providers: readonly string[];
|
|
42
64
|
private readonly _metadata;
|
|
65
|
+
/**
|
|
66
|
+
* Execution providers that were asked for, after defaults were applied.
|
|
67
|
+
*
|
|
68
|
+
* Kept separate because ORT-Web falls back silently: a page that asks for
|
|
69
|
+
* `webgpu` on a device without it runs on WASM and is told nothing.
|
|
70
|
+
*/
|
|
71
|
+
readonly requestedProviders: readonly string[];
|
|
43
72
|
private constructor();
|
|
44
73
|
/**
|
|
45
74
|
* Load an ONNX model into an ORT inference session.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/core/session.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,KAAK,GAAG,MAAM,iBAAiB,CAAC;AAI5C,OAAO,EAAE,KAAK,aAAa,EAAsB,MAAM,YAAY,CAAC;AAIpE,kDAAkD;AAClD,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,eAAe,GAAG,UAAU,CAAC;AA+ChE,MAAM,WAAW,iBAAiB;IAChC
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/core/session.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,KAAK,GAAG,MAAM,iBAAiB,CAAC;AAI5C,OAAO,EAAE,KAAK,aAAa,EAAsB,MAAM,YAAY,CAAC;AAIpE,kDAAkD;AAClD,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,eAAe,GAAG,UAAU,CAAC;AA+ChE,MAAM,WAAW,iBAAiB;IAChC;;;;;OAKG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACvC,2EAA2E;IAC3E,QAAQ,CAAC,cAAc,CAAC,EAAE,GAAG,CAAC,gBAAgB,CAAC,cAAc,CAAC;IAC9D;;;;;;;;;;;;;;;;OAgBG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC;CACjC;AA4BD;;;;;;GAMG;AACH,qBAAa,UAAU;IAEnB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB;;;;;;;;;;;;;;;;OAgBG;aACa,SAAS,EAAE,SAAS,MAAM,EAAE;IAC5C,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B;;;;;OAKG;aACa,kBAAkB,EAAE,SAAS,MAAM,EAAE;IA3BvD,OAAO;IA8BP;;;;;;;;;;;;;;;;;OAiBG;WACU,MAAM,CACjB,KAAK,EAAE,WAAW,EAClB,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,UAAU,CAAC;IAuCtB,yDAAyD;IACzD,IAAI,UAAU,IAAI,SAAS,MAAM,EAAE,CAElC;IAED,kDAAkD;IAClD,IAAI,SAAS,IAAI,MAAM,CAMtB;IAED,0DAA0D;IAC1D,IAAI,WAAW,IAAI,SAAS,MAAM,EAAE,CAEnC;IAED;;;;;;OAMG;IACH,IAAI,WAAW,IAAI,SAAS,aAAa,EAAE,CAM1C;IAED;;;;OAIG;IACH,IAAI,UAAU,IAAI,aAAa,CAE9B;IAED;;;;;OAKG;IACH,IAAI,YAAY,IAAI,SAAS,aAAa,EAAE,CAM3C;IAED;;;;OAIG;IACH,IAAI,WAAW,IAAI,aAAa,CAE/B;IAED;;;;;;;OAOG;IACH,IAAI,QAAQ,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAE/C;IAED;;;;;;;OAOG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAI9B,wEAAwE;IACxE,IAAI,GAAG,IAAI,GAAG,CAAC,gBAAgB,CAE9B;IAED;;;;;OAKG;IACG,GAAG,CACP,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,GAChC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAWvC"}
|
package/dist/core/session.js
CHANGED
|
@@ -5,7 +5,7 @@ import * as ortRuntime from "onnxruntime-web";
|
|
|
5
5
|
import { InferenceError, ModelLoadError } from "./exceptions.js";
|
|
6
6
|
import { declaredShapesFrom } from "./graph.js";
|
|
7
7
|
import { readModelMetadata } from "./metadata.js";
|
|
8
|
-
import { resolveProviders } from "./providers.js";
|
|
8
|
+
import { FALLBACK_PROVIDER, detectProviders, resolveProviders } from "./providers.js";
|
|
9
9
|
/**
|
|
10
10
|
* Fetch a model URL as bytes so its metadata can be read.
|
|
11
11
|
*
|
|
@@ -48,6 +48,26 @@ function warnMetadataUnavailable(url, reason) {
|
|
|
48
48
|
"class names are unavailable, so labels fall back to class_0, class_1, ... " +
|
|
49
49
|
"Pass `labels` explicitly to name them.");
|
|
50
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Warn when a provider named explicitly by the caller is not going to run.
|
|
53
|
+
*
|
|
54
|
+
* Only explicit requests are worth a warning. The default list exists precisely
|
|
55
|
+
* so that falling from `webgpu` to `wasm` is the expected outcome — but a caller
|
|
56
|
+
* who wrote `providers: ["webgpu"]` and lands on WASM has a page several times
|
|
57
|
+
* slower than intended and nothing in the console to explain it.
|
|
58
|
+
*
|
|
59
|
+
* @param requested Providers that were asked for.
|
|
60
|
+
* @param effective Providers that survived capability detection.
|
|
61
|
+
*/
|
|
62
|
+
function warnOnDroppedProviders(requested, effective) {
|
|
63
|
+
const dropped = requested.filter((provider) => !effective.includes(provider));
|
|
64
|
+
if (dropped.length === 0) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
console.warn(`This browser cannot offer the requested execution provider(s) ${JSON.stringify(dropped)}; ` +
|
|
68
|
+
`the session will run on ${JSON.stringify(effective)}. Inference still produces correct ` +
|
|
69
|
+
"results, on the fallback provider.");
|
|
70
|
+
}
|
|
51
71
|
/**
|
|
52
72
|
* Wrap an ONNX Runtime Web `InferenceSession` with convenient metadata access.
|
|
53
73
|
*
|
|
@@ -59,10 +79,37 @@ export class OrtSession {
|
|
|
59
79
|
_session;
|
|
60
80
|
providers;
|
|
61
81
|
_metadata;
|
|
62
|
-
|
|
82
|
+
requestedProviders;
|
|
83
|
+
constructor(_session,
|
|
84
|
+
/**
|
|
85
|
+
* Execution providers this session is expected to run on.
|
|
86
|
+
*
|
|
87
|
+
* The requested list narrowed to what this browser can actually offer — a
|
|
88
|
+
* `webgpu` entry survives only where an adapter exists. Best-effort: ORT-Web
|
|
89
|
+
* exposes no way to ask which provider a session ended up on, so an entry
|
|
90
|
+
* here means "not ruled out", not "confirmed". See
|
|
91
|
+
* {@link requestedProviders} for what was asked for.
|
|
92
|
+
*
|
|
93
|
+
* When nothing survives — a caller asking for `webgpu` alone on a device
|
|
94
|
+
* without it — this falls back to {@link FALLBACK_PROVIDER}, which ORT-Web
|
|
95
|
+
* can always run. Handing ORT the unsatisfiable list instead makes
|
|
96
|
+
* `InferenceSession.create` reject with "no available backend found", so the
|
|
97
|
+
* page gets no inference at all rather than the slow-but-working fallback
|
|
98
|
+
* the `console.warn` describes. Measured in a real Chromium, where
|
|
99
|
+
* `navigator.gpu` exists but yields no adapter.
|
|
100
|
+
*/
|
|
101
|
+
providers, _metadata,
|
|
102
|
+
/**
|
|
103
|
+
* Execution providers that were asked for, after defaults were applied.
|
|
104
|
+
*
|
|
105
|
+
* Kept separate because ORT-Web falls back silently: a page that asks for
|
|
106
|
+
* `webgpu` on a device without it runs on WASM and is told nothing.
|
|
107
|
+
*/
|
|
108
|
+
requestedProviders) {
|
|
63
109
|
this._session = _session;
|
|
64
110
|
this.providers = providers;
|
|
65
111
|
this._metadata = _metadata;
|
|
112
|
+
this.requestedProviders = requestedProviders;
|
|
66
113
|
}
|
|
67
114
|
/**
|
|
68
115
|
* Load an ONNX model into an ORT inference session.
|
|
@@ -83,7 +130,12 @@ export class OrtSession {
|
|
|
83
130
|
* @throws {@link ModelLoadError} if the model cannot be loaded.
|
|
84
131
|
*/
|
|
85
132
|
static async create(model, options = {}) {
|
|
86
|
-
const
|
|
133
|
+
const requested = resolveProviders(options.providers);
|
|
134
|
+
const detected = await detectProviders(requested);
|
|
135
|
+
const providers = detected.length > 0 ? detected : [FALLBACK_PROVIDER];
|
|
136
|
+
if (options.providers !== undefined && options.providers.length > 0) {
|
|
137
|
+
warnOnDroppedProviders(requested, providers);
|
|
138
|
+
}
|
|
87
139
|
const sessionOptions = {
|
|
88
140
|
...(options.sessionOptions ?? {}),
|
|
89
141
|
executionProviders: providers,
|
|
@@ -106,7 +158,7 @@ export class OrtSession {
|
|
|
106
158
|
catch (err) {
|
|
107
159
|
throw new ModelLoadError(`Failed to load ONNX model: ${err.message}`, { cause: err });
|
|
108
160
|
}
|
|
109
|
-
return new OrtSession(session, providers, metadata);
|
|
161
|
+
return new OrtSession(session, providers, metadata, requested);
|
|
110
162
|
}
|
|
111
163
|
/** Names of the model's inputs, in declaration order. */
|
|
112
164
|
get inputNames() {
|
package/dist/core/session.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/core/session.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAsB,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/core/session.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAsB,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAKtF;;;;;;;;;GASG;AACH,KAAK,UAAU,UAAU,CAAC,GAAW;IACnC,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;QAClC,IAAI,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AC,WAAW,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACnC,CAAC;IAED;;;;;OAKG;IACH,IAAI,YAAY;QACd,OAAO,kBAAkB,CACvB,IAAI,CAAC,QAAQ,CAAC,cAED,CACd,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACpC,CAAC;IAED;;;;;;;OAOG;IACH,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,OAAO;QACX,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IACvD,CAAC;IAED,wEAAwE;IACxE,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,GAAG,CACP,KAAiC;QAEjC,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YAC9C,OAAO,MAAoC,CAAC;QAC9C,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,IAAI,cAAc,CACtB,qBAAsB,GAAa,CAAC,OAAO,EAAE,EAC7C,EAAE,KAAK,EAAE,GAAG,EAAE,CACf,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
|
package/dist/fusion.d.ts
CHANGED
|
@@ -46,7 +46,14 @@ export declare const INPUT_SOURCE = "source_image";
|
|
|
46
46
|
export declare const INPUT_SCALE = "letterbox_scale";
|
|
47
47
|
/** Name of the `[2]` float32 `[padLeft, padTop]`. Only with `cropSource === "original"`. */
|
|
48
48
|
export declare const INPUT_PAD = "letterbox_pad";
|
|
49
|
-
/**
|
|
49
|
+
/**
|
|
50
|
+
* Name of the `[K, 4]` float32 xyxy output, in **letterboxed** input pixels.
|
|
51
|
+
*
|
|
52
|
+
* A file fused by `ort-vision-sdk` 0.9.0 or later reports the box that was
|
|
53
|
+
* actually classified: clamped to the image the crop came from, exactly as
|
|
54
|
+
* RoiAlign received it. Older files report the raw box, so one that ran off the
|
|
55
|
+
* frame draws a rectangle wider than the region the classifier saw.
|
|
56
|
+
*/
|
|
50
57
|
export declare const OUTPUT_BOXES = "boxes";
|
|
51
58
|
/** Name of the `[K]` float32 detection-confidence output. */
|
|
52
59
|
export declare const OUTPUT_SCORES = "scores";
|
package/dist/fusion.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fusion.d.ts","sourceRoot":"","sources":["../src/fusion.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH;;;;;;;;;GASG;AACH,MAAM,MAAM,UAAU,GAAG,gBAAgB,GAAG,UAAU,CAAC;AAEvD,+EAA+E;AAC/E,eAAO,MAAM,2BAA2B,oBAAoB,CAAC;AAE7D;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,SAAS,CAAC;AAEtC,gGAAgG;AAChG,eAAO,MAAM,WAAW,WAAW,CAAC;AAEpC,wFAAwF;AACxF,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAE3C,+FAA+F;AAC/F,eAAO,MAAM,WAAW,oBAAoB,CAAC;AAE7C,4FAA4F;AAC5F,eAAO,MAAM,SAAS,kBAAkB,CAAC;AAEzC
|
|
1
|
+
{"version":3,"file":"fusion.d.ts","sourceRoot":"","sources":["../src/fusion.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH;;;;;;;;;GASG;AACH,MAAM,MAAM,UAAU,GAAG,gBAAgB,GAAG,UAAU,CAAC;AAEvD,+EAA+E;AAC/E,eAAO,MAAM,2BAA2B,oBAAoB,CAAC;AAE7D;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,SAAS,CAAC;AAEtC,g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0DAA0D;IAC1D,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,gFAAgF;IAChF,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;CACpC;AA8CD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,SAAS,GACrD,UAAU,GAAG,IAAI,CAmCnB"}
|
package/dist/fusion.js
CHANGED
|
@@ -36,7 +36,14 @@ export const INPUT_SOURCE = "source_image";
|
|
|
36
36
|
export const INPUT_SCALE = "letterbox_scale";
|
|
37
37
|
/** Name of the `[2]` float32 `[padLeft, padTop]`. Only with `cropSource === "original"`. */
|
|
38
38
|
export const INPUT_PAD = "letterbox_pad";
|
|
39
|
-
/**
|
|
39
|
+
/**
|
|
40
|
+
* Name of the `[K, 4]` float32 xyxy output, in **letterboxed** input pixels.
|
|
41
|
+
*
|
|
42
|
+
* A file fused by `ort-vision-sdk` 0.9.0 or later reports the box that was
|
|
43
|
+
* actually classified: clamped to the image the crop came from, exactly as
|
|
44
|
+
* RoiAlign received it. Older files report the raw box, so one that ran off the
|
|
45
|
+
* frame draws a rectangle wider than the region the classifier saw.
|
|
46
|
+
*/
|
|
40
47
|
export const OUTPUT_BOXES = "boxes";
|
|
41
48
|
/** Name of the `[K]` float32 detection-confidence output. */
|
|
42
49
|
export const OUTPUT_SCORES = "scores";
|
package/dist/fusion.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fusion.js","sourceRoot":"","sources":["../src/fusion.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAchD,+EAA+E;AAC/E,MAAM,CAAC,MAAM,2BAA2B,GAAG,iBAAiB,CAAC;AAE7D;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,MAA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,2BAA2B;QACjC,SAAS;QACT,QAAQ;QACR,UAAU;QACV,aAAa;QACb,aAAa,EAAE,WAAW,CAAC,IAAI,CAAC,kBAAkB,CAAC,EAAE,IAAI,CAAC;QAC1D,YAAY,EAAE,WAAW,CAAC,IAAI,CAAC,iBAAiB,CAAC,EAAE,IAAI,CAAC;QACxD,YAAY,EAAE,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,GAAG,CAAC,KAAK,GAAG;QACtD,aAAa,EAAE,UAAU,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QACnD,eAAe,EAAE,UAAU,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;QACvD,UAAU,EAAE,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE;QACvC,gBAAgB,EAAE,UAAU,KAAK,UAAU;KAC5C,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -9,8 +9,9 @@ export { FusionError, ImageLoadError, InferenceError, LabelMapError, ModelLoadEr
|
|
|
9
9
|
export { type ModelSource, type OrtSessionOptions, OrtSession, } from "./core/session.js";
|
|
10
10
|
export { type DeclaredDim, type DeclaredShape, type ResolveInputSizeOptions, classificationNumClasses, declaredShapesFrom, detectionNumClasses, resolveInputSize, spatialInputSize, } from "./core/graph.js";
|
|
11
11
|
export { modelNames, parseNames, readModelMetadata } from "./core/metadata.js";
|
|
12
|
-
export { DEFAULT_PROVIDERS, resolveProviders } from "./core/providers.js";
|
|
12
|
+
export { DEFAULT_PROVIDERS, detectProviders, resolveProviders } from "./core/providers.js";
|
|
13
13
|
export { type Speed, SpeedTimer } from "./core/timing.js";
|
|
14
|
+
export { CUSTOM_NORMALIZATION, IDENTITY_MEAN, IDENTITY_STD, IMAGENET_MEAN, IMAGENET_STD, type Normalization, type ResolvedNormalization, isUltralyticsClassifier, resolveNormalization, } from "./normalization.js";
|
|
14
15
|
export { type ImageInput, loadImage } from "./io/image.js";
|
|
15
16
|
export { FUSION_KIND_DETECT_CLASSIFY, INPUT_IMAGE, INPUT_PAD, INPUT_SCALE, INPUT_SOURCE, METADATA_PREFIX, OUTPUT_BOXES, OUTPUT_CLASSES, OUTPUT_NUM_DETECTIONS, OUTPUT_PROBS, OUTPUT_SCORES, type CropSource, type FusionSpec, readFusionSpec, } from "./fusion.js";
|
|
16
17
|
export { type LetterboxResult, fromCv2, letterbox, normalize, resize, toCHW, toCv2, toFloat32, toFloat32Tensor, toTensor, } from "./preprocess/image.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,WAAW,EACX,IAAI,EACJ,QAAQ,EACR,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,KAAK,kBAAkB,GACxB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,KAAK,EACL,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,EAChB,KAAK,EACL,KAAK,EACL,mBAAmB,GACpB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,YAAY,EACZ,KAAK,SAAS,EACd,KAAK,oBAAoB,EACzB,aAAa,EACb,aAAa,GACd,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,WAAW,EACX,cAAc,EACd,cAAc,EACd,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,yBAAyB,GAC1B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,UAAU,GACX,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,uBAAuB,EAC5B,wBAAwB,EACxB,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,UAAU,EAA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,qBAAqB,EAC1B,KAAK,4BAA4B,EACjC,cAAc,GACf,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,QAAQ,GACT,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAC5B,SAAS,GACV,MAAM,sBAAsB,CAAC;AAE9B,eAAO,MAAM,OAAO,EAAE,MAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -9,8 +9,9 @@ export { FusionError, ImageLoadError, InferenceError, LabelMapError, ModelLoadEr
|
|
|
9
9
|
export { OrtSession, } from "./core/session.js";
|
|
10
10
|
export { classificationNumClasses, declaredShapesFrom, detectionNumClasses, resolveInputSize, spatialInputSize, } from "./core/graph.js";
|
|
11
11
|
export { modelNames, parseNames, readModelMetadata } from "./core/metadata.js";
|
|
12
|
-
export { DEFAULT_PROVIDERS, resolveProviders } from "./core/providers.js";
|
|
12
|
+
export { DEFAULT_PROVIDERS, detectProviders, resolveProviders } from "./core/providers.js";
|
|
13
13
|
export { SpeedTimer } from "./core/timing.js";
|
|
14
|
+
export { CUSTOM_NORMALIZATION, IDENTITY_MEAN, IDENTITY_STD, IMAGENET_MEAN, IMAGENET_STD, isUltralyticsClassifier, resolveNormalization, } from "./normalization.js";
|
|
14
15
|
export { loadImage } from "./io/image.js";
|
|
15
16
|
export { FUSION_KIND_DETECT_CLASSIFY, INPUT_IMAGE, INPUT_PAD, INPUT_SCALE, INPUT_SOURCE, METADATA_PREFIX, OUTPUT_BOXES, OUTPUT_CLASSES, OUTPUT_NUM_DETECTIONS, OUTPUT_PROBS, OUTPUT_SCORES, readFusionSpec, } from "./fusion.js";
|
|
16
17
|
export { fromCv2, letterbox, normalize, resize, toCHW, toCv2, toFloat32, toFloat32Tensor, toTensor, } from "./preprocess/image.js";
|
|
@@ -23,5 +24,5 @@ export { Classifier, } from "./tasks/classifier.js";
|
|
|
23
24
|
export { DetectClassify, } from "./tasks/detectClassify.js";
|
|
24
25
|
export { Detector, } from "./tasks/detector.js";
|
|
25
26
|
export { Segmenter, } from "./tasks/segmenter.js";
|
|
26
|
-
export const VERSION = "0.
|
|
27
|
+
export const VERSION = "0.8.0";
|
|
27
28
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,WAAW,EACX,IAAI,EACJ,QAAQ,GAKT,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,KAAK,EACL,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,EAChB,KAAK,EACL,KAAK,EACL,mBAAmB,GACpB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,YAAY,EAGZ,aAAa,EACb,aAAa,GACd,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,WAAW,EACX,cAAc,EACd,cAAc,EACd,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,yBAAyB,GAC1B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAGL,UAAU,GACX,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAIL,wBAAwB,EACxB,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC/E,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,WAAW,EACX,IAAI,EACJ,QAAQ,GAKT,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,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EACrB,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,GACf,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAEL,OAAO,EACP,IAAI,GACL,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAKL,UAAU,EACV,UAAU,EACV,iBAAiB,EACjB,GAAG,GACJ,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAGL,aAAa,GACd,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAGL,UAAU,GACX,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAGL,cAAc,GACf,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAIL,QAAQ,GACT,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAIL,SAAS,GACV,MAAM,sBAAsB,CAAC;AAE9B,MAAM,CAAC,MAAM,OAAO,GAAW,OAAO,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which preprocessing a classifier expects its input to have had.
|
|
3
|
+
*
|
|
4
|
+
* A classifier is trained on a specific tensor, and feeding it a differently
|
|
5
|
+
* prepared one degrades it silently — no exception, no warning, just worse
|
|
6
|
+
* predictions. The two families this SDK sees most disagree completely:
|
|
7
|
+
* torchvision-style models want the ImageNet mean and deviation subtracted and
|
|
8
|
+
* divided out, while an Ultralytics classification head consumes raw `[0, 1]`.
|
|
9
|
+
*
|
|
10
|
+
* Guessing wrong is not detectable from the outside, but it is not a guess: an
|
|
11
|
+
* Ultralytics export stamps `author` and `task` into its own metadata, and every
|
|
12
|
+
* task in this SDK already reads that map for the class names.
|
|
13
|
+
*
|
|
14
|
+
* Mirrors `ort_vision_sdk.normalization` in the Python SDK; the two must agree,
|
|
15
|
+
* because the same model file is driven by both.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Which preprocessing the classifier expects its input to have had.
|
|
19
|
+
*
|
|
20
|
+
* - `"auto"` (the default wherever it is accepted) reads the model's own export
|
|
21
|
+
* metadata and picks. An Ultralytics classification head gets
|
|
22
|
+
* `"ultralytics"`; anything else gets `"imagenet"`.
|
|
23
|
+
* - `"imagenet"` subtracts the ImageNet mean and divides by the ImageNet
|
|
24
|
+
* deviation — the torchvision convention.
|
|
25
|
+
* - `"ultralytics"` leaves the image in `[0, 1]`. Ultralytics' own classifier
|
|
26
|
+
* applies no mean/std at all, so anything else feeds it images it never saw
|
|
27
|
+
* in training.
|
|
28
|
+
* - `"none"` is the same arithmetic as `"ultralytics"` — identity — under a
|
|
29
|
+
* name that says "this model wants raw `[0, 1]`" rather than naming a vendor.
|
|
30
|
+
*/
|
|
31
|
+
export type Normalization = "auto" | "imagenet" | "ultralytics" | "none";
|
|
32
|
+
/** Per-channel RGB mean of ImageNet, the torchvision preprocessing convention. */
|
|
33
|
+
export declare const IMAGENET_MEAN: readonly [number, number, number];
|
|
34
|
+
/** Per-channel RGB standard deviation of ImageNet. */
|
|
35
|
+
export declare const IMAGENET_STD: readonly [number, number, number];
|
|
36
|
+
/** Mean that leaves an image untouched — what an Ultralytics classifier expects. */
|
|
37
|
+
export declare const IDENTITY_MEAN: readonly [number, number, number];
|
|
38
|
+
/** Deviation that leaves an image untouched — what an Ultralytics classifier expects. */
|
|
39
|
+
export declare const IDENTITY_STD: readonly [number, number, number];
|
|
40
|
+
/** Name reported when the caller supplied `mean`/`std` directly. */
|
|
41
|
+
export declare const CUSTOM_NORMALIZATION = "custom";
|
|
42
|
+
/** What {@link resolveNormalization} settled on. */
|
|
43
|
+
export interface ResolvedNormalization {
|
|
44
|
+
/** The preset name, or `"custom"` when the caller supplied the values. */
|
|
45
|
+
readonly name: string;
|
|
46
|
+
/** Per-channel mean to subtract. */
|
|
47
|
+
readonly mean: readonly [number, number, number];
|
|
48
|
+
/** Per-channel deviation to divide by. */
|
|
49
|
+
readonly std: readonly [number, number, number];
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Whether a metadata map came out of `YOLO(...).export(format="onnx")`.
|
|
53
|
+
*
|
|
54
|
+
* Every Ultralytics export stamps `author` and `task` into its metadata, and the
|
|
55
|
+
* pair is unambiguous: `"Ultralytics"` plus `"classify"` is a classification head
|
|
56
|
+
* from that codebase and nothing else.
|
|
57
|
+
*
|
|
58
|
+
* @param metadata The model's custom metadata map.
|
|
59
|
+
*/
|
|
60
|
+
export declare function isUltralyticsClassifier(metadata: Readonly<Record<string, string>>): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Settle which `mean`/`std` to apply, and what to call the choice.
|
|
63
|
+
*
|
|
64
|
+
* Explicit `mean`/`std` always win — they are the escape hatch for a model whose
|
|
65
|
+
* preprocessing neither preset describes. Anything they leave open falls back to
|
|
66
|
+
* the preset, so passing only a `mean` does not silently reset the deviation
|
|
67
|
+
* to 1.
|
|
68
|
+
*
|
|
69
|
+
* Warns (via `console.warn`) when the model is an Ultralytics export and the
|
|
70
|
+
* supplied values are not the identity it was trained with. Nothing fails in
|
|
71
|
+
* that case: the prediction has the right shape and is simply less accurate,
|
|
72
|
+
* which is exactly why it is worth saying out loud.
|
|
73
|
+
*
|
|
74
|
+
* @param metadata The model's custom metadata map, read to detect the family.
|
|
75
|
+
* @param options The preset asked for, plus any explicit `mean`/`std`.
|
|
76
|
+
* @throws {RangeError} If `normalization` is not a known preset, or names one
|
|
77
|
+
* while `mean`/`std` are also supplied — two answers to the same question.
|
|
78
|
+
*/
|
|
79
|
+
export declare function resolveNormalization(metadata: Readonly<Record<string, string>>, options?: {
|
|
80
|
+
readonly normalization?: Normalization;
|
|
81
|
+
readonly mean?: readonly [number, number, number];
|
|
82
|
+
readonly std?: readonly [number, number, number];
|
|
83
|
+
}): ResolvedNormalization;
|
|
84
|
+
//# sourceMappingURL=normalization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalization.d.ts","sourceRoot":"","sources":["../src/normalization.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;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EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAClD,QAAQ,CAAC,GAAG,CAAC,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;CAC7C,GACL,qBAAqB,CAwCvB"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which preprocessing a classifier expects its input to have had.
|
|
3
|
+
*
|
|
4
|
+
* A classifier is trained on a specific tensor, and feeding it a differently
|
|
5
|
+
* prepared one degrades it silently — no exception, no warning, just worse
|
|
6
|
+
* predictions. The two families this SDK sees most disagree completely:
|
|
7
|
+
* torchvision-style models want the ImageNet mean and deviation subtracted and
|
|
8
|
+
* divided out, while an Ultralytics classification head consumes raw `[0, 1]`.
|
|
9
|
+
*
|
|
10
|
+
* Guessing wrong is not detectable from the outside, but it is not a guess: an
|
|
11
|
+
* Ultralytics export stamps `author` and `task` into its own metadata, and every
|
|
12
|
+
* task in this SDK already reads that map for the class names.
|
|
13
|
+
*
|
|
14
|
+
* Mirrors `ort_vision_sdk.normalization` in the Python SDK; the two must agree,
|
|
15
|
+
* because the same model file is driven by both.
|
|
16
|
+
*/
|
|
17
|
+
/** Per-channel RGB mean of ImageNet, the torchvision preprocessing convention. */
|
|
18
|
+
export const IMAGENET_MEAN = [0.485, 0.456, 0.406];
|
|
19
|
+
/** Per-channel RGB standard deviation of ImageNet. */
|
|
20
|
+
export const IMAGENET_STD = [0.229, 0.224, 0.225];
|
|
21
|
+
/** Mean that leaves an image untouched — what an Ultralytics classifier expects. */
|
|
22
|
+
export const IDENTITY_MEAN = [0, 0, 0];
|
|
23
|
+
/** Deviation that leaves an image untouched — what an Ultralytics classifier expects. */
|
|
24
|
+
export const IDENTITY_STD = [1, 1, 1];
|
|
25
|
+
/** Name reported when the caller supplied `mean`/`std` directly. */
|
|
26
|
+
export const CUSTOM_NORMALIZATION = "custom";
|
|
27
|
+
const PRESETS = {
|
|
28
|
+
imagenet: [IMAGENET_MEAN, IMAGENET_STD],
|
|
29
|
+
ultralytics: [IDENTITY_MEAN, IDENTITY_STD],
|
|
30
|
+
none: [IDENTITY_MEAN, IDENTITY_STD],
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Whether a metadata map came out of `YOLO(...).export(format="onnx")`.
|
|
34
|
+
*
|
|
35
|
+
* Every Ultralytics export stamps `author` and `task` into its metadata, and the
|
|
36
|
+
* pair is unambiguous: `"Ultralytics"` plus `"classify"` is a classification head
|
|
37
|
+
* from that codebase and nothing else.
|
|
38
|
+
*
|
|
39
|
+
* @param metadata The model's custom metadata map.
|
|
40
|
+
*/
|
|
41
|
+
export function isUltralyticsClassifier(metadata) {
|
|
42
|
+
return ((metadata.author ?? "").trim().toLowerCase() === "ultralytics" &&
|
|
43
|
+
(metadata.task ?? "").trim().toLowerCase() === "classify");
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Settle which `mean`/`std` to apply, and what to call the choice.
|
|
47
|
+
*
|
|
48
|
+
* Explicit `mean`/`std` always win — they are the escape hatch for a model whose
|
|
49
|
+
* preprocessing neither preset describes. Anything they leave open falls back to
|
|
50
|
+
* the preset, so passing only a `mean` does not silently reset the deviation
|
|
51
|
+
* to 1.
|
|
52
|
+
*
|
|
53
|
+
* Warns (via `console.warn`) when the model is an Ultralytics export and the
|
|
54
|
+
* supplied values are not the identity it was trained with. Nothing fails in
|
|
55
|
+
* that case: the prediction has the right shape and is simply less accurate,
|
|
56
|
+
* which is exactly why it is worth saying out loud.
|
|
57
|
+
*
|
|
58
|
+
* @param metadata The model's custom metadata map, read to detect the family.
|
|
59
|
+
* @param options The preset asked for, plus any explicit `mean`/`std`.
|
|
60
|
+
* @throws {RangeError} If `normalization` is not a known preset, or names one
|
|
61
|
+
* while `mean`/`std` are also supplied — two answers to the same question.
|
|
62
|
+
*/
|
|
63
|
+
export function resolveNormalization(metadata, options = {}) {
|
|
64
|
+
const normalization = options.normalization ?? "auto";
|
|
65
|
+
const explicit = options.mean !== undefined || options.std !== undefined;
|
|
66
|
+
if (normalization !== "auto" && PRESETS[normalization] === undefined) {
|
|
67
|
+
throw new RangeError(`normalization must be one of 'auto', 'imagenet', 'ultralytics', 'none'; ` +
|
|
68
|
+
`got ${JSON.stringify(normalization)}.`);
|
|
69
|
+
}
|
|
70
|
+
if (explicit && normalization !== "auto") {
|
|
71
|
+
throw new RangeError(`Pass either normalization=${JSON.stringify(normalization)} or explicit mean/std, not both.`);
|
|
72
|
+
}
|
|
73
|
+
const ultralytics = isUltralyticsClassifier(metadata);
|
|
74
|
+
const preset = normalization === "auto" ? (ultralytics ? "ultralytics" : "imagenet") : normalization;
|
|
75
|
+
const [presetMean, presetStd] = PRESETS[preset];
|
|
76
|
+
if (!explicit) {
|
|
77
|
+
return { name: preset, mean: presetMean, std: presetStd };
|
|
78
|
+
}
|
|
79
|
+
const mean = options.mean ?? presetMean;
|
|
80
|
+
const std = options.std ?? presetStd;
|
|
81
|
+
if (ultralytics && !(isIdentity(mean, IDENTITY_MEAN) && isIdentity(std, IDENTITY_STD))) {
|
|
82
|
+
console.warn("The classifier is an Ultralytics export, whose classification head is trained on raw " +
|
|
83
|
+
`[0, 1] images, but mean=${JSON.stringify(mean)} / std=${JSON.stringify(std)} was ` +
|
|
84
|
+
"requested. It will be fed images normalized in a way it never saw in training, which " +
|
|
85
|
+
"degrades accuracy without raising anything. Drop mean/std to let normalization='auto' " +
|
|
86
|
+
"pick the identity.");
|
|
87
|
+
}
|
|
88
|
+
return { name: CUSTOM_NORMALIZATION, mean, std };
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Whether two channel triples are equal.
|
|
92
|
+
*
|
|
93
|
+
* @param value The triple to check.
|
|
94
|
+
* @param reference The triple to compare against.
|
|
95
|
+
*/
|
|
96
|
+
function isIdentity(value, reference) {
|
|
97
|
+
return value.every((entry, index) => entry === reference[index]);
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=normalization.js.map
|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AAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO;YACnF,uFAAuF;YACvF,wFAAwF;YACxF,oBAAoB,CACvB,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,oBAAoB,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;AACnD,CAAC;AAED;;;;;GAKG;AACH,SAAS,UAAU,CACjB,KAAwC,EACxC,SAA4C;IAE5C,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;AACnE,CAAC"}
|
|
@@ -55,7 +55,6 @@ export declare class LetterboxPipeline {
|
|
|
55
55
|
private readonly _buffer;
|
|
56
56
|
private _source;
|
|
57
57
|
private _sourceContext;
|
|
58
|
-
private _bufferInUse;
|
|
59
58
|
/**
|
|
60
59
|
* @param targetWidth Model input width in pixels.
|
|
61
60
|
* @param targetHeight Model input height in pixels.
|
|
@@ -71,7 +70,9 @@ export declare class LetterboxPipeline {
|
|
|
71
70
|
* still checked out — {@link release} marks it free again. A second `run`
|
|
72
71
|
* before the first is released allocates a fresh buffer rather than
|
|
73
72
|
* corrupting it, so concurrent `predict()` calls on one task stay correct at
|
|
74
|
-
* the cost of the allocation they were trying to avoid.
|
|
73
|
+
* the cost of the allocation they were trying to avoid. A buffer that was
|
|
74
|
+
* detached by a consumer that transferred it is replaced rather than written
|
|
75
|
+
* into — see {@link ReusableBuffer}.
|
|
75
76
|
*
|
|
76
77
|
* @param image Source image in the SDK's canonical HWC RGB layout.
|
|
77
78
|
*/
|
|
@@ -156,7 +157,6 @@ export declare class ResizePipeline {
|
|
|
156
157
|
private _targetContext;
|
|
157
158
|
private _source;
|
|
158
159
|
private _sourceContext;
|
|
159
|
-
private _bufferInUse;
|
|
160
160
|
/**
|
|
161
161
|
* @param targetWidth Model input width in pixels.
|
|
162
162
|
* @param targetHeight Model input height in pixels.
|
|
@@ -174,6 +174,9 @@ export declare class ResizePipeline {
|
|
|
174
174
|
* keeps the result identical to `resize()`, whose own fast path returns the
|
|
175
175
|
* input untouched.
|
|
176
176
|
*
|
|
177
|
+
* Buffer reuse follows {@link ReusableBuffer}: held across calls, replaced when
|
|
178
|
+
* a consumer detached it by transferring the tensor.
|
|
179
|
+
*
|
|
177
180
|
* @param image Source image in the SDK's canonical HWC RGB layout.
|
|
178
181
|
*/
|
|
179
182
|
run(image: RGBImage): FusedResizeResult;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../src/preprocess/pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../src/preprocess/pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AA+DvC,wEAAwE;AACxE,MAAM,WAAW,oBAAoB;IACnC,wEAAwE;IACxE,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,kEAAkE;IAClE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,oCAAoC;IACpC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,kCAAkC;IAClC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CAC1B;AAED;;;;;;GAMG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IACtC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;IACvC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAoC;IAC1D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAW;IACnC,OAAO,C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B,GACxD,oBAAoB,CAEtB"}
|
|
@@ -22,6 +22,55 @@
|
|
|
22
22
|
*/
|
|
23
23
|
import { createCanvas, get2DContext, rgbToImageData } from "../core/canvas.js";
|
|
24
24
|
const INV_255 = 1 / 255;
|
|
25
|
+
/**
|
|
26
|
+
* A `Float32Array` held across calls, handed out one claim at a time.
|
|
27
|
+
*
|
|
28
|
+
* Both pipelines want the same thing — allocate once, write into it every frame,
|
|
29
|
+
* and fall back to a fresh array when a previous result has not been released
|
|
30
|
+
* yet — so the bookkeeping lives here instead of twice.
|
|
31
|
+
*
|
|
32
|
+
* The part that is not obvious is {@link claim} re-allocating a buffer that is
|
|
33
|
+
* *detached*. `ort.env.wasm.proxy` runs ONNX Runtime in a worker and posts the
|
|
34
|
+
* input tensors with their `ArrayBuffer`s in the transfer list, which detaches
|
|
35
|
+
* them on this side. A detached `Float32Array` is silently 0 long: writing to it
|
|
36
|
+
* is a no-op, and the next `InferenceSession.run` rejects with
|
|
37
|
+
* `Tensor's size(N) does not match data length(0)` on every other call — once for
|
|
38
|
+
* the detached buffer, then the throw leaves the claim outstanding so the call
|
|
39
|
+
* after it allocates and succeeds. Treating a buffer that changed length as spent
|
|
40
|
+
* turns that into one extra allocation per transfer, which is what reuse was
|
|
41
|
+
* avoiding, and keeps it correct for any consumer that transfers the tensor
|
|
42
|
+
* rather than copying it.
|
|
43
|
+
*/
|
|
44
|
+
class ReusableBuffer {
|
|
45
|
+
_size;
|
|
46
|
+
_buffer;
|
|
47
|
+
_inUse = false;
|
|
48
|
+
/** @param size Length in floats of every buffer this hands out. */
|
|
49
|
+
constructor(size) {
|
|
50
|
+
this._size = size;
|
|
51
|
+
this._buffer = new Float32Array(size);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Take the held buffer, or a fresh one when it is unavailable.
|
|
55
|
+
*
|
|
56
|
+
* Unavailable means either still checked out by an unreleased claim, or
|
|
57
|
+
* detached by whoever it was handed to. The first case allocates for this call
|
|
58
|
+
* only; the second replaces the held buffer, so the allocation is paid once per
|
|
59
|
+
* transfer rather than on every call after it.
|
|
60
|
+
*/
|
|
61
|
+
claim() {
|
|
62
|
+
if (this._inUse)
|
|
63
|
+
return { data: new Float32Array(this._size), reused: false };
|
|
64
|
+
if (this._buffer.length !== this._size)
|
|
65
|
+
this._buffer = new Float32Array(this._size);
|
|
66
|
+
this._inUse = true;
|
|
67
|
+
return { data: this._buffer, reused: true };
|
|
68
|
+
}
|
|
69
|
+
/** Mark the held buffer free for the next {@link claim}. */
|
|
70
|
+
release() {
|
|
71
|
+
this._inUse = false;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
25
74
|
/**
|
|
26
75
|
* Reusable letterbox → tensor pipeline for one target resolution.
|
|
27
76
|
*
|
|
@@ -38,7 +87,6 @@ export class LetterboxPipeline {
|
|
|
38
87
|
_buffer;
|
|
39
88
|
_source = null;
|
|
40
89
|
_sourceContext = null;
|
|
41
|
-
_bufferInUse = false;
|
|
42
90
|
/**
|
|
43
91
|
* @param targetWidth Model input width in pixels.
|
|
44
92
|
* @param targetHeight Model input height in pixels.
|
|
@@ -55,7 +103,7 @@ export class LetterboxPipeline {
|
|
|
55
103
|
this._targetContext = get2DContext(this._target, { willReadFrequently: true });
|
|
56
104
|
this._targetContext.imageSmoothingEnabled = true;
|
|
57
105
|
this._targetContext.imageSmoothingQuality = "high";
|
|
58
|
-
this._buffer = new
|
|
106
|
+
this._buffer = new ReusableBuffer(3 * targetHeight * targetWidth);
|
|
59
107
|
}
|
|
60
108
|
/** The `[width, height]` this pipeline letterboxes into. */
|
|
61
109
|
get targetSize() {
|
|
@@ -68,7 +116,9 @@ export class LetterboxPipeline {
|
|
|
68
116
|
* still checked out — {@link release} marks it free again. A second `run`
|
|
69
117
|
* before the first is released allocates a fresh buffer rather than
|
|
70
118
|
* corrupting it, so concurrent `predict()` calls on one task stay correct at
|
|
71
|
-
* the cost of the allocation they were trying to avoid.
|
|
119
|
+
* the cost of the allocation they were trying to avoid. A buffer that was
|
|
120
|
+
* detached by a consumer that transferred it is replaced rather than written
|
|
121
|
+
* into — see {@link ReusableBuffer}.
|
|
72
122
|
*
|
|
73
123
|
* @param image Source image in the SDK's canonical HWC RGB layout.
|
|
74
124
|
*/
|
|
@@ -89,9 +139,7 @@ export class LetterboxPipeline {
|
|
|
89
139
|
}
|
|
90
140
|
context.drawImage(this._source, 0, 0, image.width, image.height, padLeft, padTop, scaledWidth, scaledHeight);
|
|
91
141
|
const rgba = context.getImageData(0, 0, targetWidth, targetHeight).data;
|
|
92
|
-
const reused =
|
|
93
|
-
const data = reused ? this._buffer : new Float32Array(3 * targetHeight * targetWidth);
|
|
94
|
-
this._bufferInUse = true;
|
|
142
|
+
const { data, reused } = this._buffer.claim();
|
|
95
143
|
const plane = targetWidth * targetHeight;
|
|
96
144
|
for (let pixel = 0, offset = 0; pixel < plane; pixel++, offset += 4) {
|
|
97
145
|
data[pixel] = rgba[offset] * INV_255;
|
|
@@ -108,7 +156,7 @@ export class LetterboxPipeline {
|
|
|
108
156
|
* the WASM heap and the buffer can be overwritten.
|
|
109
157
|
*/
|
|
110
158
|
release() {
|
|
111
|
-
this.
|
|
159
|
+
this._buffer.release();
|
|
112
160
|
}
|
|
113
161
|
/**
|
|
114
162
|
* Grow the scratch source canvas to fit an image, reusing it when possible.
|
|
@@ -189,7 +237,6 @@ export class ResizePipeline {
|
|
|
189
237
|
_targetContext = null;
|
|
190
238
|
_source = null;
|
|
191
239
|
_sourceContext = null;
|
|
192
|
-
_bufferInUse = false;
|
|
193
240
|
/**
|
|
194
241
|
* @param targetWidth Model input width in pixels.
|
|
195
242
|
* @param targetHeight Model input height in pixels.
|
|
@@ -204,7 +251,7 @@ export class ResizePipeline {
|
|
|
204
251
|
this._targetHeight = targetHeight;
|
|
205
252
|
this._mean = mean;
|
|
206
253
|
this._std = std;
|
|
207
|
-
this._buffer = new
|
|
254
|
+
this._buffer = new ReusableBuffer(3 * targetHeight * targetWidth);
|
|
208
255
|
}
|
|
209
256
|
/** The `[width, height]` this pipeline resizes into. */
|
|
210
257
|
get targetSize() {
|
|
@@ -218,14 +265,15 @@ export class ResizePipeline {
|
|
|
218
265
|
* keeps the result identical to `resize()`, whose own fast path returns the
|
|
219
266
|
* input untouched.
|
|
220
267
|
*
|
|
268
|
+
* Buffer reuse follows {@link ReusableBuffer}: held across calls, replaced when
|
|
269
|
+
* a consumer detached it by transferring the tensor.
|
|
270
|
+
*
|
|
221
271
|
* @param image Source image in the SDK's canonical HWC RGB layout.
|
|
222
272
|
*/
|
|
223
273
|
run(image) {
|
|
224
274
|
const targetWidth = this._targetWidth;
|
|
225
275
|
const targetHeight = this._targetHeight;
|
|
226
|
-
const reused =
|
|
227
|
-
const data = reused ? this._buffer : new Float32Array(3 * targetHeight * targetWidth);
|
|
228
|
-
this._bufferInUse = true;
|
|
276
|
+
const { data, reused } = this._buffer.claim();
|
|
229
277
|
if (image.width === targetWidth && image.height === targetHeight) {
|
|
230
278
|
writePlanarFloat32(image.data, targetWidth, targetHeight, this._mean, this._std, data, 3);
|
|
231
279
|
return { data, reused };
|
|
@@ -246,7 +294,7 @@ export class ResizePipeline {
|
|
|
246
294
|
* the WASM heap and the buffer can be overwritten.
|
|
247
295
|
*/
|
|
248
296
|
release() {
|
|
249
|
-
this.
|
|
297
|
+
this._buffer.release();
|
|
250
298
|
}
|
|
251
299
|
/**
|
|
252
300
|
* Build the target canvas on first use.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline.js","sourceRoot":"","sources":["../../src/preprocess/pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,cAAc,EAAiC,MAAM,mBAAmB,CAAC;AAG9G,MAAM,OAAO,GAAG,CAAC,GAAG,GAAG,CAAC;
|
|
1
|
+
{"version":3,"file":"pipeline.js","sourceRoot":"","sources":["../../src/preprocess/pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;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
|
|
5
5
|
import { type ImageInput } from "../io/image.js";
|
|
6
6
|
import { type LabelSpec } from "../labels.js";
|
|
7
|
+
import { type Normalization } from "../normalization.js";
|
|
7
8
|
import { ClassificationResults } from "../results.js";
|
|
8
9
|
import { VisionTask } from "./base.js";
|
|
9
10
|
export interface ClassifierOptions extends OrtSessionOptions {
|
|
@@ -31,14 +32,27 @@ export interface ClassifierOptions extends OrtSessionOptions {
|
|
|
31
32
|
* Runtime will accept. Defaults to `[224, 224]`.
|
|
32
33
|
*/
|
|
33
34
|
readonly inputSize?: readonly [number, number];
|
|
34
|
-
/**
|
|
35
|
+
/**
|
|
36
|
+
* Which preprocessing this model expects — see {@link Normalization}.
|
|
37
|
+
*
|
|
38
|
+
* Defaults to `"auto"`, which reads the model's own export metadata and picks
|
|
39
|
+
* `"ultralytics"` (raw `[0, 1]`) for an Ultralytics classification head and
|
|
40
|
+
* `"imagenet"` for everything else.
|
|
41
|
+
*/
|
|
42
|
+
readonly normalization?: Normalization;
|
|
43
|
+
/** Per-channel RGB mean, overriding the preset. Defaults to the preset's. */
|
|
35
44
|
readonly mean?: readonly [number, number, number];
|
|
36
|
-
/** Per-channel RGB standard deviation
|
|
45
|
+
/** Per-channel RGB standard deviation, overriding the preset. */
|
|
37
46
|
readonly std?: readonly [number, number, number];
|
|
38
47
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
48
|
+
* Whether the model's output still needs a softmax.
|
|
49
|
+
*
|
|
50
|
+
* Left undefined (the default), this reads the model's metadata and answers
|
|
51
|
+
* `false` for an Ultralytics classification export, whose graph already ends
|
|
52
|
+
* in one — applying a second softmax to a probability vector keeps the
|
|
53
|
+
* ranking but flattens the confidences, so the top-1 stays right while every
|
|
54
|
+
* number attached to it is wrong. Detection covers that family; for any other
|
|
55
|
+
* model that already emits probabilities, pass `false` explicitly.
|
|
42
56
|
*/
|
|
43
57
|
readonly applySoftmax?: boolean;
|
|
44
58
|
}
|
|
@@ -78,7 +92,27 @@ export declare class Classifier extends VisionTask {
|
|
|
78
92
|
private readonly _mean;
|
|
79
93
|
private readonly _std;
|
|
80
94
|
private readonly _applySoftmax;
|
|
95
|
+
private readonly _normalization;
|
|
81
96
|
private constructor();
|
|
97
|
+
/**
|
|
98
|
+
* Whether a softmax is applied to the model's output before ranking.
|
|
99
|
+
*
|
|
100
|
+
* Resolved once at construction. Worth reading when confidences look
|
|
101
|
+
* compressed: a second softmax over an already-normalized vector leaves the
|
|
102
|
+
* ordering intact and the numbers meaningless, which is invisible to any check
|
|
103
|
+
* that only looks at the predicted class.
|
|
104
|
+
*/
|
|
105
|
+
get appliesSoftmax(): boolean;
|
|
106
|
+
/**
|
|
107
|
+
* Which preprocessing this classifier applies to every image.
|
|
108
|
+
*
|
|
109
|
+
* One of the {@link Normalization} preset names, or `"custom"` when the caller
|
|
110
|
+
* supplied `mean`/`std` directly. Worth reading when a model underperforms:
|
|
111
|
+
* feeding a classifier a differently prepared tensor than it was trained on
|
|
112
|
+
* degrades it without throwing anything, so "what does this assume" is the
|
|
113
|
+
* first question.
|
|
114
|
+
*/
|
|
115
|
+
get normalization(): string;
|
|
82
116
|
private _pipelineCache;
|
|
83
117
|
/**
|
|
84
118
|
* Run the model once on a zero tensor, paying one-time costs up front.
|
|
@@ -101,7 +135,14 @@ export declare class Classifier extends VisionTask {
|
|
|
101
135
|
* fails if it is actually asked to preprocess something.
|
|
102
136
|
*/
|
|
103
137
|
private get _pipeline();
|
|
104
|
-
/**
|
|
138
|
+
/**
|
|
139
|
+
* Load the model, resolve labels, and settle the preprocessing.
|
|
140
|
+
*
|
|
141
|
+
* @param model The model source — a URL, or the bytes.
|
|
142
|
+
* @param options Labels, input size, normalization, and session options.
|
|
143
|
+
* @throws {RangeError} If `normalization` names an unknown preset, or names
|
|
144
|
+
* one while `mean`/`std` are also given.
|
|
145
|
+
*/
|
|
105
146
|
static create(model: ModelSource, options?: ClassifierOptions): Promise<Classifier>;
|
|
106
147
|
/** Class labels indexed by class id. */
|
|
107
148
|
get labels(): readonly string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"classifier.d.ts","sourceRoot":"","sources":["../../src/tasks/classifier.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,iBAAiB,EAAc,MAAM,oBAAoB,CAAC;AAE1F,OAAO,EAAE,KAAK,UAAU,EAAa,MAAM,gBAAgB,CAAC;AAG5D,OAAO,EAAE,KAAK,SAAS,EAAiB,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"classifier.d.ts","sourceRoot":"","sources":["../../src/tasks/classifier.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,iBAAiB,EAAc,MAAM,oBAAoB,CAAC;AAE1F,OAAO,EAAE,KAAK,UAAU,EAAa,MAAM,gBAAgB,CAAC;AAG5D,OAAO,EAAE,KAAK,SAAS,EAAiB,MAAM,cAAc,CAAC;AAC7D,OAAO,EACL,KAAK,aAAa,EAGnB,MAAM,qBAAqB,CAAC;AAI7B,OAAO,EAAE,qBAAqB,EAAS,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAOvC,MAAM,WAAW,iBAAkB,SAAQ,iBAAiB;IAC1D;;;;;;;OAOG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC;IAC5B;;;;;OAKG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B;;;;;;OAMG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/C;;;;;;OAMG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,aAAa,CAAC;IACvC,6EAA6E;IAC7E,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CA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AAM,EAAE,MAAM,CAAC,CAEzC;IAED,+CAA+C;IAC/C,IAAI,UAAU,IAAI,MAAM,CAEvB;IAED,4EAA4E;IACtE,IAAI,CACR,KAAK,EAAE,UAAU,EACjB,OAAO,GAAE,wBAA6B,GACrC,OAAO,CAAC,qBAAqB,EAAE,CAAC;IAInC,4CAA4C;IACtC,OAAO,CACX,KAAK,EAAE,UAAU,EACjB,OAAO,GAAE,wBAA6B,GACrC,OAAO,CAAC,qBAAqB,EAAE,CAAC;IAkEnC,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,YAAY;CAGrB"}
|
package/dist/tasks/classifier.js
CHANGED
|
@@ -7,13 +7,12 @@ import { loadImage } from "../io/image.js";
|
|
|
7
7
|
import { classificationNumClasses, resolveInputSize } from "../core/graph.js";
|
|
8
8
|
import { modelNames } from "../core/metadata.js";
|
|
9
9
|
import { resolveLabels } from "../labels.js";
|
|
10
|
+
import { isUltralyticsClassifier, resolveNormalization, } from "../normalization.js";
|
|
10
11
|
import { softmax, topK } from "../postprocess/classification.js";
|
|
11
12
|
import { toFloat32Tensor } from "../preprocess/image.js";
|
|
12
13
|
import { ResizePipeline, zeroTensorData } from "../preprocess/pipeline.js";
|
|
13
14
|
import { ClassificationResults, Probs } from "../results.js";
|
|
14
15
|
import { VisionTask } from "./base.js";
|
|
15
|
-
const IMAGENET_MEAN = [0.485, 0.456, 0.406];
|
|
16
|
-
const IMAGENET_STD = [0.229, 0.224, 0.225];
|
|
17
16
|
/**
|
|
18
17
|
* Image classifier wrapping an ONNX model with ImageNet-style preprocessing.
|
|
19
18
|
*
|
|
@@ -42,7 +41,8 @@ export class Classifier extends VisionTask {
|
|
|
42
41
|
_mean;
|
|
43
42
|
_std;
|
|
44
43
|
_applySoftmax;
|
|
45
|
-
|
|
44
|
+
_normalization;
|
|
45
|
+
constructor(session, _labels, _names, _inputSize, _mean, _std, _applySoftmax, _normalization) {
|
|
46
46
|
super(session);
|
|
47
47
|
this._labels = _labels;
|
|
48
48
|
this._names = _names;
|
|
@@ -50,6 +50,30 @@ export class Classifier extends VisionTask {
|
|
|
50
50
|
this._mean = _mean;
|
|
51
51
|
this._std = _std;
|
|
52
52
|
this._applySoftmax = _applySoftmax;
|
|
53
|
+
this._normalization = _normalization;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Whether a softmax is applied to the model's output before ranking.
|
|
57
|
+
*
|
|
58
|
+
* Resolved once at construction. Worth reading when confidences look
|
|
59
|
+
* compressed: a second softmax over an already-normalized vector leaves the
|
|
60
|
+
* ordering intact and the numbers meaningless, which is invisible to any check
|
|
61
|
+
* that only looks at the predicted class.
|
|
62
|
+
*/
|
|
63
|
+
get appliesSoftmax() {
|
|
64
|
+
return this._applySoftmax;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Which preprocessing this classifier applies to every image.
|
|
68
|
+
*
|
|
69
|
+
* One of the {@link Normalization} preset names, or `"custom"` when the caller
|
|
70
|
+
* supplied `mean`/`std` directly. Worth reading when a model underperforms:
|
|
71
|
+
* feeding a classifier a differently prepared tensor than it was trained on
|
|
72
|
+
* degrades it without throwing anything, so "what does this assume" is the
|
|
73
|
+
* first question.
|
|
74
|
+
*/
|
|
75
|
+
get normalization() {
|
|
76
|
+
return this._normalization;
|
|
53
77
|
}
|
|
54
78
|
_pipelineCache = null;
|
|
55
79
|
/**
|
|
@@ -85,9 +109,21 @@ export class Classifier extends VisionTask {
|
|
|
85
109
|
}
|
|
86
110
|
return this._pipelineCache;
|
|
87
111
|
}
|
|
88
|
-
/**
|
|
112
|
+
/**
|
|
113
|
+
* Load the model, resolve labels, and settle the preprocessing.
|
|
114
|
+
*
|
|
115
|
+
* @param model The model source — a URL, or the bytes.
|
|
116
|
+
* @param options Labels, input size, normalization, and session options.
|
|
117
|
+
* @throws {RangeError} If `normalization` names an unknown preset, or names
|
|
118
|
+
* one while `mean`/`std` are also given.
|
|
119
|
+
*/
|
|
89
120
|
static async create(model, options = {}) {
|
|
90
121
|
const session = await OrtSession.create(model, options);
|
|
122
|
+
const normalization = resolveNormalization(session.metadata, {
|
|
123
|
+
normalization: options.normalization,
|
|
124
|
+
mean: options.mean,
|
|
125
|
+
std: options.std,
|
|
126
|
+
});
|
|
91
127
|
const numClasses = options.numClasses ?? classificationNumClasses(session.outputShape) ?? undefined;
|
|
92
128
|
const labels = resolveLabels(options.labels ?? modelNames(session.metadata), {
|
|
93
129
|
numClasses,
|
|
@@ -100,7 +136,7 @@ export class Classifier extends VisionTask {
|
|
|
100
136
|
graphShape: session.inputShape,
|
|
101
137
|
requested: options.inputSize,
|
|
102
138
|
fallback: [224, 224],
|
|
103
|
-
}),
|
|
139
|
+
}), normalization.mean, normalization.std, options.applySoftmax ?? !isUltralyticsClassifier(session.metadata), normalization.name);
|
|
104
140
|
}
|
|
105
141
|
/** Class labels indexed by class id. */
|
|
106
142
|
get labels() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"classifier.js","sourceRoot":"","sources":["../../src/tasks/classifier.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAA4C,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC1F,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAmB,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAkB,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAC7D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