hyperframes 0.6.104 → 0.6.105
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/dist/cli.js +32 -1603
- package/dist/studio/assets/{index-JOvcn0L_.js → index-By4Ku5HI.js} +1 -1
- package/dist/studio/assets/{index-CtVcyRD2.js → index-CKd39gmy.js} +2 -2
- package/dist/studio/assets/{index-_elwW-31.js → index-NIdeStFw.js} +1 -1
- package/dist/studio/index.html +1 -1
- package/package.json +5 -5
- package/dist/onnxruntime_binding-2BPLI7ZQ.node +0 -0
- package/dist/onnxruntime_binding-5J67DTMJ.node +0 -0
- package/dist/onnxruntime_binding-7ZZLEQ2F.node +0 -0
- package/dist/onnxruntime_binding-KDCXAPN5.node +0 -0
- package/dist/onnxruntime_binding-R73P2IQW.node +0 -0
package/dist/cli.js
CHANGED
|
@@ -17,11 +17,6 @@ var __require = /* @__PURE__ */ ((x3) => typeof require !== "undefined" ? requir
|
|
|
17
17
|
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
18
18
|
throw Error('Dynamic require of "' + x3 + '" is not supported');
|
|
19
19
|
});
|
|
20
|
-
var __glob = (map) => (path2) => {
|
|
21
|
-
var fn = map[path2];
|
|
22
|
-
if (fn) return fn();
|
|
23
|
-
throw new Error("Module not found in bundle: " + path2);
|
|
24
|
-
};
|
|
25
20
|
var __esm = (fn, res) => function __init() {
|
|
26
21
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
27
22
|
};
|
|
@@ -55,7 +50,7 @@ var VERSION;
|
|
|
55
50
|
var init_version = __esm({
|
|
56
51
|
"src/version.ts"() {
|
|
57
52
|
"use strict";
|
|
58
|
-
VERSION = true ? "0.6.
|
|
53
|
+
VERSION = true ? "0.6.105" : "0.0.0-dev";
|
|
59
54
|
}
|
|
60
55
|
});
|
|
61
56
|
|
|
@@ -11776,7 +11771,7 @@ var require_canvas = __commonJS({
|
|
|
11776
11771
|
});
|
|
11777
11772
|
|
|
11778
11773
|
// ../../node_modules/.bun/linkedom@0.18.12/node_modules/linkedom/esm/html/canvas-element.js
|
|
11779
|
-
var import_canvas, createCanvas, tagName7,
|
|
11774
|
+
var import_canvas, createCanvas, tagName7, HTMLCanvasElement;
|
|
11780
11775
|
var init_canvas_element = __esm({
|
|
11781
11776
|
"../../node_modules/.bun/linkedom@0.18.12/node_modules/linkedom/esm/html/canvas-element.js"() {
|
|
11782
11777
|
"use strict";
|
|
@@ -11787,7 +11782,7 @@ var init_canvas_element = __esm({
|
|
|
11787
11782
|
init_element3();
|
|
11788
11783
|
({ createCanvas } = import_canvas.default);
|
|
11789
11784
|
tagName7 = "canvas";
|
|
11790
|
-
|
|
11785
|
+
HTMLCanvasElement = class extends HTMLElement2 {
|
|
11791
11786
|
constructor(ownerDocument, localName = tagName7) {
|
|
11792
11787
|
super(ownerDocument, localName);
|
|
11793
11788
|
this[IMAGE] = createCanvas(300, 150);
|
|
@@ -11813,7 +11808,7 @@ var init_canvas_element = __esm({
|
|
|
11813
11808
|
return this[IMAGE].toDataURL(...args);
|
|
11814
11809
|
}
|
|
11815
11810
|
};
|
|
11816
|
-
registerHTMLClass(tagName7,
|
|
11811
|
+
registerHTMLClass(tagName7, HTMLCanvasElement);
|
|
11817
11812
|
}
|
|
11818
11813
|
});
|
|
11819
11814
|
|
|
@@ -12340,7 +12335,7 @@ var init_form_element = __esm({
|
|
|
12340
12335
|
});
|
|
12341
12336
|
|
|
12342
12337
|
// ../../node_modules/.bun/linkedom@0.18.12/node_modules/linkedom/esm/html/image-element.js
|
|
12343
|
-
var tagName15,
|
|
12338
|
+
var tagName15, HTMLImageElement;
|
|
12344
12339
|
var init_image_element = __esm({
|
|
12345
12340
|
"../../node_modules/.bun/linkedom@0.18.12/node_modules/linkedom/esm/html/image-element.js"() {
|
|
12346
12341
|
"use strict";
|
|
@@ -12348,7 +12343,7 @@ var init_image_element = __esm({
|
|
|
12348
12343
|
init_attributes();
|
|
12349
12344
|
init_element3();
|
|
12350
12345
|
tagName15 = "img";
|
|
12351
|
-
|
|
12346
|
+
HTMLImageElement = class extends HTMLElement2 {
|
|
12352
12347
|
constructor(ownerDocument, localName = tagName15) {
|
|
12353
12348
|
super(ownerDocument, localName);
|
|
12354
12349
|
}
|
|
@@ -12397,7 +12392,7 @@ var init_image_element = __esm({
|
|
|
12397
12392
|
}
|
|
12398
12393
|
/* c8 ignore stop */
|
|
12399
12394
|
};
|
|
12400
|
-
registerHTMLClass(tagName15,
|
|
12395
|
+
registerHTMLClass(tagName15, HTMLImageElement);
|
|
12401
12396
|
}
|
|
12402
12397
|
});
|
|
12403
12398
|
|
|
@@ -12816,7 +12811,7 @@ var init_html_classes = __esm({
|
|
|
12816
12811
|
HTMLHeadingElement,
|
|
12817
12812
|
HTMLDirectoryElement,
|
|
12818
12813
|
HTMLQuoteElement,
|
|
12819
|
-
HTMLCanvasElement
|
|
12814
|
+
HTMLCanvasElement,
|
|
12820
12815
|
HTMLLegendElement,
|
|
12821
12816
|
HTMLOptionElement,
|
|
12822
12817
|
HTMLSpanElement,
|
|
@@ -12840,7 +12835,7 @@ var init_html_classes = __esm({
|
|
|
12840
12835
|
HTMLLinkElement,
|
|
12841
12836
|
HTMLSlotElement,
|
|
12842
12837
|
HTMLFormElement,
|
|
12843
|
-
HTMLImageElement
|
|
12838
|
+
HTMLImageElement,
|
|
12844
12839
|
HTMLPreElement,
|
|
12845
12840
|
HTMLUListElement,
|
|
12846
12841
|
HTMLMetaElement,
|
|
@@ -12940,7 +12935,7 @@ var init_image = __esm({
|
|
|
12940
12935
|
/**
|
|
12941
12936
|
* @implements globalThis.Image
|
|
12942
12937
|
*/
|
|
12943
|
-
class Image extends
|
|
12938
|
+
class Image extends HTMLImageElement {
|
|
12944
12939
|
constructor(width, height) {
|
|
12945
12940
|
super(ownerDocument);
|
|
12946
12941
|
switch (arguments.length) {
|
|
@@ -55424,8 +55419,11 @@ async function launchBrowser(chromeArgs, config) {
|
|
|
55424
55419
|
protocolTimeout
|
|
55425
55420
|
});
|
|
55426
55421
|
const browserVersion = await browser.version().catch(() => "unknown");
|
|
55422
|
+
const gpuFlags = chromeArgs.filter(
|
|
55423
|
+
(a) => a.startsWith("--use-gl=") || a.startsWith("--use-angle=")
|
|
55424
|
+
);
|
|
55427
55425
|
console.log(
|
|
55428
|
-
`[BrowserManager] Browser launched (${browserVersion}, ${captureMode}, headlessShell=${!!headlessShell}, platform=${process.platform})`
|
|
55426
|
+
`[BrowserManager] Browser launched (${browserVersion}, ${captureMode}, gl=${gpuFlags.join(" ") || "default"}, headlessShell=${!!headlessShell}, platform=${process.platform})`
|
|
55429
55427
|
);
|
|
55430
55428
|
if (captureMode === "beginframe") {
|
|
55431
55429
|
const supported = await probeBeginFrameSupport(browser).catch(() => true);
|
|
@@ -55618,7 +55616,13 @@ function getBrowserGpuArgs(mode, platform10) {
|
|
|
55618
55616
|
case "win32":
|
|
55619
55617
|
return ["--use-gl=angle", "--use-angle=d3d11", "--enable-gpu-rasterization"];
|
|
55620
55618
|
case "linux":
|
|
55621
|
-
return [
|
|
55619
|
+
return [
|
|
55620
|
+
"--use-gl=angle",
|
|
55621
|
+
"--use-angle=gl-egl",
|
|
55622
|
+
"--enable-gpu-rasterization",
|
|
55623
|
+
"--ignore-gpu-blocklist",
|
|
55624
|
+
"--disable-software-rasterizer"
|
|
55625
|
+
];
|
|
55622
55626
|
default:
|
|
55623
55627
|
return ["--enable-gpu-rasterization"];
|
|
55624
55628
|
}
|
|
@@ -57002,7 +57006,7 @@ function getProbeArgs(encoder) {
|
|
|
57002
57006
|
"-f",
|
|
57003
57007
|
"lavfi",
|
|
57004
57008
|
"-i",
|
|
57005
|
-
|
|
57009
|
+
`color=size=${GPU_PROBE_WIDTH}x${GPU_PROBE_HEIGHT}:rate=1:duration=1`,
|
|
57006
57010
|
"-frames:v",
|
|
57007
57011
|
"1",
|
|
57008
57012
|
"-an"
|
|
@@ -57078,7 +57082,7 @@ function mapPresetForGpuEncoder(encoder, preset) {
|
|
|
57078
57082
|
return preset;
|
|
57079
57083
|
}
|
|
57080
57084
|
}
|
|
57081
|
-
var GPU_ENCODER_CANDIDATES, H264_ENCODER_BY_GPU, GPU_PROBE_TIMEOUT_MS, GPU_PROBE_KILL_GRACE_MS, cachedGpuEncoder, NVENC_PRESET_MAP, QSV_PRESET_MAP;
|
|
57085
|
+
var GPU_ENCODER_CANDIDATES, H264_ENCODER_BY_GPU, GPU_PROBE_TIMEOUT_MS, GPU_PROBE_KILL_GRACE_MS, cachedGpuEncoder, GPU_PROBE_WIDTH, GPU_PROBE_HEIGHT, NVENC_PRESET_MAP, QSV_PRESET_MAP;
|
|
57082
57086
|
var init_gpuEncoder = __esm({
|
|
57083
57087
|
"../engine/src/utils/gpuEncoder.ts"() {
|
|
57084
57088
|
"use strict";
|
|
@@ -57100,6 +57104,8 @@ var init_gpuEncoder = __esm({
|
|
|
57100
57104
|
GPU_PROBE_TIMEOUT_MS = 2e3;
|
|
57101
57105
|
GPU_PROBE_KILL_GRACE_MS = 1e3;
|
|
57102
57106
|
cachedGpuEncoder = void 0;
|
|
57107
|
+
GPU_PROBE_WIDTH = 320;
|
|
57108
|
+
GPU_PROBE_HEIGHT = 240;
|
|
57103
57109
|
NVENC_PRESET_MAP = {
|
|
57104
57110
|
ultrafast: "p1",
|
|
57105
57111
|
superfast: "p1",
|
|
@@ -104851,1585 +104857,6 @@ var init_manager3 = __esm({
|
|
|
104851
104857
|
}
|
|
104852
104858
|
});
|
|
104853
104859
|
|
|
104854
|
-
// ../../node_modules/.bun/onnxruntime-common@1.26.0/node_modules/onnxruntime-common/dist/cjs/backend-impl.js
|
|
104855
|
-
var require_backend_impl = __commonJS({
|
|
104856
|
-
"../../node_modules/.bun/onnxruntime-common@1.26.0/node_modules/onnxruntime-common/dist/cjs/backend-impl.js"(exports) {
|
|
104857
|
-
"use strict";
|
|
104858
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
104859
|
-
exports.resolveBackendAndExecutionProviders = exports.registerBackend = void 0;
|
|
104860
|
-
var backends = /* @__PURE__ */ new Map();
|
|
104861
|
-
var backendsSortedByPriority = [];
|
|
104862
|
-
var registerBackend = (name, backend, priority) => {
|
|
104863
|
-
if (backend && typeof backend.init === "function" && typeof backend.createInferenceSessionHandler === "function") {
|
|
104864
|
-
const currentBackend = backends.get(name);
|
|
104865
|
-
if (currentBackend === void 0) {
|
|
104866
|
-
backends.set(name, { backend, priority });
|
|
104867
|
-
} else if (currentBackend.priority > priority) {
|
|
104868
|
-
return;
|
|
104869
|
-
} else if (currentBackend.priority === priority) {
|
|
104870
|
-
if (currentBackend.backend !== backend) {
|
|
104871
|
-
throw new Error(`cannot register backend "${name}" using priority ${priority}`);
|
|
104872
|
-
}
|
|
104873
|
-
}
|
|
104874
|
-
if (priority >= 0) {
|
|
104875
|
-
const i2 = backendsSortedByPriority.indexOf(name);
|
|
104876
|
-
if (i2 !== -1) {
|
|
104877
|
-
backendsSortedByPriority.splice(i2, 1);
|
|
104878
|
-
}
|
|
104879
|
-
for (let i3 = 0; i3 < backendsSortedByPriority.length; i3++) {
|
|
104880
|
-
if (backends.get(backendsSortedByPriority[i3]).priority <= priority) {
|
|
104881
|
-
backendsSortedByPriority.splice(i3, 0, name);
|
|
104882
|
-
return;
|
|
104883
|
-
}
|
|
104884
|
-
}
|
|
104885
|
-
backendsSortedByPriority.push(name);
|
|
104886
|
-
}
|
|
104887
|
-
return;
|
|
104888
|
-
}
|
|
104889
|
-
throw new TypeError("not a valid backend");
|
|
104890
|
-
};
|
|
104891
|
-
exports.registerBackend = registerBackend;
|
|
104892
|
-
var tryResolveAndInitializeBackend = async (backendName) => {
|
|
104893
|
-
const backendInfo = backends.get(backendName);
|
|
104894
|
-
if (!backendInfo) {
|
|
104895
|
-
return "backend not found.";
|
|
104896
|
-
}
|
|
104897
|
-
if (backendInfo.initialized) {
|
|
104898
|
-
return backendInfo.backend;
|
|
104899
|
-
} else if (backendInfo.aborted) {
|
|
104900
|
-
return backendInfo.error;
|
|
104901
|
-
} else {
|
|
104902
|
-
const isInitializing = !!backendInfo.initPromise;
|
|
104903
|
-
try {
|
|
104904
|
-
if (!isInitializing) {
|
|
104905
|
-
backendInfo.initPromise = backendInfo.backend.init(backendName);
|
|
104906
|
-
}
|
|
104907
|
-
await backendInfo.initPromise;
|
|
104908
|
-
backendInfo.initialized = true;
|
|
104909
|
-
return backendInfo.backend;
|
|
104910
|
-
} catch (e3) {
|
|
104911
|
-
if (!isInitializing) {
|
|
104912
|
-
backendInfo.error = `${e3}`;
|
|
104913
|
-
backendInfo.aborted = true;
|
|
104914
|
-
}
|
|
104915
|
-
return backendInfo.error;
|
|
104916
|
-
} finally {
|
|
104917
|
-
delete backendInfo.initPromise;
|
|
104918
|
-
}
|
|
104919
|
-
}
|
|
104920
|
-
};
|
|
104921
|
-
var resolveBackendAndExecutionProviders = async (options) => {
|
|
104922
|
-
const eps = options.executionProviders || [];
|
|
104923
|
-
const backendHints = eps.map((i2) => typeof i2 === "string" ? i2 : i2.name);
|
|
104924
|
-
const backendNames = backendHints.length === 0 ? backendsSortedByPriority : backendHints;
|
|
104925
|
-
let backend;
|
|
104926
|
-
const errors = [];
|
|
104927
|
-
const availableBackendNames = /* @__PURE__ */ new Set();
|
|
104928
|
-
for (const backendName of backendNames) {
|
|
104929
|
-
const resolveResult = await tryResolveAndInitializeBackend(backendName);
|
|
104930
|
-
if (typeof resolveResult === "string") {
|
|
104931
|
-
errors.push({ name: backendName, err: resolveResult });
|
|
104932
|
-
} else {
|
|
104933
|
-
if (!backend) {
|
|
104934
|
-
backend = resolveResult;
|
|
104935
|
-
}
|
|
104936
|
-
if (backend === resolveResult) {
|
|
104937
|
-
availableBackendNames.add(backendName);
|
|
104938
|
-
}
|
|
104939
|
-
}
|
|
104940
|
-
}
|
|
104941
|
-
if (!backend) {
|
|
104942
|
-
throw new Error(`no available backend found. ERR: ${errors.map((e3) => `[${e3.name}] ${e3.err}`).join(", ")}`);
|
|
104943
|
-
}
|
|
104944
|
-
for (const { name, err } of errors) {
|
|
104945
|
-
if (backendHints.includes(name)) {
|
|
104946
|
-
console.warn(`removing requested execution provider "${name}" from session options because it is not available: ${err}`);
|
|
104947
|
-
}
|
|
104948
|
-
}
|
|
104949
|
-
const filteredEps = eps.filter((i2) => availableBackendNames.has(typeof i2 === "string" ? i2 : i2.name));
|
|
104950
|
-
return [
|
|
104951
|
-
backend,
|
|
104952
|
-
new Proxy(options, {
|
|
104953
|
-
get: (target, prop2) => {
|
|
104954
|
-
if (prop2 === "executionProviders") {
|
|
104955
|
-
return filteredEps;
|
|
104956
|
-
}
|
|
104957
|
-
return Reflect.get(target, prop2);
|
|
104958
|
-
}
|
|
104959
|
-
})
|
|
104960
|
-
];
|
|
104961
|
-
};
|
|
104962
|
-
exports.resolveBackendAndExecutionProviders = resolveBackendAndExecutionProviders;
|
|
104963
|
-
}
|
|
104964
|
-
});
|
|
104965
|
-
|
|
104966
|
-
// ../../node_modules/.bun/onnxruntime-common@1.26.0/node_modules/onnxruntime-common/dist/cjs/backend.js
|
|
104967
|
-
var require_backend = __commonJS({
|
|
104968
|
-
"../../node_modules/.bun/onnxruntime-common@1.26.0/node_modules/onnxruntime-common/dist/cjs/backend.js"(exports) {
|
|
104969
|
-
"use strict";
|
|
104970
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
104971
|
-
exports.registerBackend = void 0;
|
|
104972
|
-
var backend_impl_js_1 = require_backend_impl();
|
|
104973
|
-
Object.defineProperty(exports, "registerBackend", { enumerable: true, get: function() {
|
|
104974
|
-
return backend_impl_js_1.registerBackend;
|
|
104975
|
-
} });
|
|
104976
|
-
}
|
|
104977
|
-
});
|
|
104978
|
-
|
|
104979
|
-
// ../../node_modules/.bun/onnxruntime-common@1.26.0/node_modules/onnxruntime-common/dist/cjs/version.js
|
|
104980
|
-
var require_version = __commonJS({
|
|
104981
|
-
"../../node_modules/.bun/onnxruntime-common@1.26.0/node_modules/onnxruntime-common/dist/cjs/version.js"(exports) {
|
|
104982
|
-
"use strict";
|
|
104983
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
104984
|
-
exports.version = void 0;
|
|
104985
|
-
exports.version = "1.26.0";
|
|
104986
|
-
}
|
|
104987
|
-
});
|
|
104988
|
-
|
|
104989
|
-
// ../../node_modules/.bun/onnxruntime-common@1.26.0/node_modules/onnxruntime-common/dist/cjs/env-impl.js
|
|
104990
|
-
var require_env_impl = __commonJS({
|
|
104991
|
-
"../../node_modules/.bun/onnxruntime-common@1.26.0/node_modules/onnxruntime-common/dist/cjs/env-impl.js"(exports) {
|
|
104992
|
-
"use strict";
|
|
104993
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
104994
|
-
exports.env = void 0;
|
|
104995
|
-
var version_js_1 = require_version();
|
|
104996
|
-
var logLevelValue = "warning";
|
|
104997
|
-
exports.env = {
|
|
104998
|
-
wasm: {},
|
|
104999
|
-
webgl: {},
|
|
105000
|
-
webgpu: {},
|
|
105001
|
-
versions: { common: version_js_1.version },
|
|
105002
|
-
set logLevel(value) {
|
|
105003
|
-
if (value === void 0) {
|
|
105004
|
-
return;
|
|
105005
|
-
}
|
|
105006
|
-
if (typeof value !== "string" || ["verbose", "info", "warning", "error", "fatal"].indexOf(value) === -1) {
|
|
105007
|
-
throw new Error(`Unsupported logging level: ${value}`);
|
|
105008
|
-
}
|
|
105009
|
-
logLevelValue = value;
|
|
105010
|
-
},
|
|
105011
|
-
get logLevel() {
|
|
105012
|
-
return logLevelValue;
|
|
105013
|
-
}
|
|
105014
|
-
};
|
|
105015
|
-
Object.defineProperty(exports.env, "logLevel", { enumerable: true });
|
|
105016
|
-
}
|
|
105017
|
-
});
|
|
105018
|
-
|
|
105019
|
-
// ../../node_modules/.bun/onnxruntime-common@1.26.0/node_modules/onnxruntime-common/dist/cjs/env.js
|
|
105020
|
-
var require_env = __commonJS({
|
|
105021
|
-
"../../node_modules/.bun/onnxruntime-common@1.26.0/node_modules/onnxruntime-common/dist/cjs/env.js"(exports) {
|
|
105022
|
-
"use strict";
|
|
105023
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
105024
|
-
exports.env = void 0;
|
|
105025
|
-
var env_impl_js_1 = require_env_impl();
|
|
105026
|
-
exports.env = env_impl_js_1.env;
|
|
105027
|
-
}
|
|
105028
|
-
});
|
|
105029
|
-
|
|
105030
|
-
// ../../node_modules/.bun/onnxruntime-common@1.26.0/node_modules/onnxruntime-common/dist/cjs/tensor-conversion-impl.js
|
|
105031
|
-
var require_tensor_conversion_impl = __commonJS({
|
|
105032
|
-
"../../node_modules/.bun/onnxruntime-common@1.26.0/node_modules/onnxruntime-common/dist/cjs/tensor-conversion-impl.js"(exports) {
|
|
105033
|
-
"use strict";
|
|
105034
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
105035
|
-
exports.tensorToImageData = exports.tensorToDataURL = void 0;
|
|
105036
|
-
var tensorToDataURL = (tensor, options) => {
|
|
105037
|
-
const canvas = typeof document !== "undefined" ? document.createElement("canvas") : new OffscreenCanvas(1, 1);
|
|
105038
|
-
canvas.width = tensor.dims[3];
|
|
105039
|
-
canvas.height = tensor.dims[2];
|
|
105040
|
-
const pixels2DContext = canvas.getContext("2d");
|
|
105041
|
-
if (pixels2DContext != null) {
|
|
105042
|
-
let width;
|
|
105043
|
-
let height;
|
|
105044
|
-
if (options?.tensorLayout !== void 0 && options.tensorLayout === "NHWC") {
|
|
105045
|
-
width = tensor.dims[2];
|
|
105046
|
-
height = tensor.dims[3];
|
|
105047
|
-
} else {
|
|
105048
|
-
width = tensor.dims[3];
|
|
105049
|
-
height = tensor.dims[2];
|
|
105050
|
-
}
|
|
105051
|
-
const inputformat = options?.format !== void 0 ? options.format : "RGB";
|
|
105052
|
-
const norm = options?.norm;
|
|
105053
|
-
let normMean;
|
|
105054
|
-
let normBias;
|
|
105055
|
-
if (norm === void 0 || norm.mean === void 0) {
|
|
105056
|
-
normMean = [255, 255, 255, 255];
|
|
105057
|
-
} else {
|
|
105058
|
-
if (typeof norm.mean === "number") {
|
|
105059
|
-
normMean = [norm.mean, norm.mean, norm.mean, norm.mean];
|
|
105060
|
-
} else {
|
|
105061
|
-
normMean = [norm.mean[0], norm.mean[1], norm.mean[2], 0];
|
|
105062
|
-
if (norm.mean[3] !== void 0) {
|
|
105063
|
-
normMean[3] = norm.mean[3];
|
|
105064
|
-
}
|
|
105065
|
-
}
|
|
105066
|
-
}
|
|
105067
|
-
if (norm === void 0 || norm.bias === void 0) {
|
|
105068
|
-
normBias = [0, 0, 0, 0];
|
|
105069
|
-
} else {
|
|
105070
|
-
if (typeof norm.bias === "number") {
|
|
105071
|
-
normBias = [norm.bias, norm.bias, norm.bias, norm.bias];
|
|
105072
|
-
} else {
|
|
105073
|
-
normBias = [norm.bias[0], norm.bias[1], norm.bias[2], 0];
|
|
105074
|
-
if (norm.bias[3] !== void 0) {
|
|
105075
|
-
normBias[3] = norm.bias[3];
|
|
105076
|
-
}
|
|
105077
|
-
}
|
|
105078
|
-
}
|
|
105079
|
-
const stride = height * width;
|
|
105080
|
-
let rTensorPointer = 0, gTensorPointer = stride, bTensorPointer = stride * 2, aTensorPointer = -1;
|
|
105081
|
-
if (inputformat === "RGBA") {
|
|
105082
|
-
rTensorPointer = 0;
|
|
105083
|
-
gTensorPointer = stride;
|
|
105084
|
-
bTensorPointer = stride * 2;
|
|
105085
|
-
aTensorPointer = stride * 3;
|
|
105086
|
-
} else if (inputformat === "RGB") {
|
|
105087
|
-
rTensorPointer = 0;
|
|
105088
|
-
gTensorPointer = stride;
|
|
105089
|
-
bTensorPointer = stride * 2;
|
|
105090
|
-
} else if (inputformat === "RBG") {
|
|
105091
|
-
rTensorPointer = 0;
|
|
105092
|
-
bTensorPointer = stride;
|
|
105093
|
-
gTensorPointer = stride * 2;
|
|
105094
|
-
}
|
|
105095
|
-
for (let i2 = 0; i2 < height; i2++) {
|
|
105096
|
-
for (let j3 = 0; j3 < width; j3++) {
|
|
105097
|
-
const R3 = (tensor.data[rTensorPointer++] - normBias[0]) * normMean[0];
|
|
105098
|
-
const G2 = (tensor.data[gTensorPointer++] - normBias[1]) * normMean[1];
|
|
105099
|
-
const B2 = (tensor.data[bTensorPointer++] - normBias[2]) * normMean[2];
|
|
105100
|
-
const A3 = aTensorPointer === -1 ? 255 : (tensor.data[aTensorPointer++] - normBias[3]) * normMean[3];
|
|
105101
|
-
pixels2DContext.fillStyle = "rgba(" + R3 + "," + G2 + "," + B2 + "," + A3 + ")";
|
|
105102
|
-
pixels2DContext.fillRect(j3, i2, 1, 1);
|
|
105103
|
-
}
|
|
105104
|
-
}
|
|
105105
|
-
if ("toDataURL" in canvas) {
|
|
105106
|
-
return canvas.toDataURL();
|
|
105107
|
-
} else {
|
|
105108
|
-
throw new Error("toDataURL is not supported");
|
|
105109
|
-
}
|
|
105110
|
-
} else {
|
|
105111
|
-
throw new Error("Can not access image data");
|
|
105112
|
-
}
|
|
105113
|
-
};
|
|
105114
|
-
exports.tensorToDataURL = tensorToDataURL;
|
|
105115
|
-
var tensorToImageData = (tensor, options) => {
|
|
105116
|
-
const pixels2DContext = typeof document !== "undefined" ? document.createElement("canvas").getContext("2d") : new OffscreenCanvas(1, 1).getContext("2d");
|
|
105117
|
-
let image;
|
|
105118
|
-
if (pixels2DContext != null) {
|
|
105119
|
-
let width;
|
|
105120
|
-
let height;
|
|
105121
|
-
let channels;
|
|
105122
|
-
if (options?.tensorLayout !== void 0 && options.tensorLayout === "NHWC") {
|
|
105123
|
-
width = tensor.dims[2];
|
|
105124
|
-
height = tensor.dims[1];
|
|
105125
|
-
channels = tensor.dims[3];
|
|
105126
|
-
} else {
|
|
105127
|
-
width = tensor.dims[3];
|
|
105128
|
-
height = tensor.dims[2];
|
|
105129
|
-
channels = tensor.dims[1];
|
|
105130
|
-
}
|
|
105131
|
-
const inputformat = options !== void 0 ? options.format !== void 0 ? options.format : "RGB" : "RGB";
|
|
105132
|
-
const norm = options?.norm;
|
|
105133
|
-
let normMean;
|
|
105134
|
-
let normBias;
|
|
105135
|
-
if (norm === void 0 || norm.mean === void 0) {
|
|
105136
|
-
normMean = [255, 255, 255, 255];
|
|
105137
|
-
} else {
|
|
105138
|
-
if (typeof norm.mean === "number") {
|
|
105139
|
-
normMean = [norm.mean, norm.mean, norm.mean, norm.mean];
|
|
105140
|
-
} else {
|
|
105141
|
-
normMean = [norm.mean[0], norm.mean[1], norm.mean[2], 255];
|
|
105142
|
-
if (norm.mean[3] !== void 0) {
|
|
105143
|
-
normMean[3] = norm.mean[3];
|
|
105144
|
-
}
|
|
105145
|
-
}
|
|
105146
|
-
}
|
|
105147
|
-
if (norm === void 0 || norm.bias === void 0) {
|
|
105148
|
-
normBias = [0, 0, 0, 0];
|
|
105149
|
-
} else {
|
|
105150
|
-
if (typeof norm.bias === "number") {
|
|
105151
|
-
normBias = [norm.bias, norm.bias, norm.bias, norm.bias];
|
|
105152
|
-
} else {
|
|
105153
|
-
normBias = [norm.bias[0], norm.bias[1], norm.bias[2], 0];
|
|
105154
|
-
if (norm.bias[3] !== void 0) {
|
|
105155
|
-
normBias[3] = norm.bias[3];
|
|
105156
|
-
}
|
|
105157
|
-
}
|
|
105158
|
-
}
|
|
105159
|
-
const stride = height * width;
|
|
105160
|
-
if (options !== void 0) {
|
|
105161
|
-
if (options.format !== void 0 && channels === 4 && options.format !== "RGBA" || channels === 3 && options.format !== "RGB" && options.format !== "BGR") {
|
|
105162
|
-
throw new Error("Tensor format doesn't match input tensor dims");
|
|
105163
|
-
}
|
|
105164
|
-
}
|
|
105165
|
-
const step = 4;
|
|
105166
|
-
let rImagePointer = 0, gImagePointer = 1, bImagePointer = 2, aImagePointer = 3;
|
|
105167
|
-
let rTensorPointer = 0, gTensorPointer = stride, bTensorPointer = stride * 2, aTensorPointer = -1;
|
|
105168
|
-
if (inputformat === "RGBA") {
|
|
105169
|
-
rTensorPointer = 0;
|
|
105170
|
-
gTensorPointer = stride;
|
|
105171
|
-
bTensorPointer = stride * 2;
|
|
105172
|
-
aTensorPointer = stride * 3;
|
|
105173
|
-
} else if (inputformat === "RGB") {
|
|
105174
|
-
rTensorPointer = 0;
|
|
105175
|
-
gTensorPointer = stride;
|
|
105176
|
-
bTensorPointer = stride * 2;
|
|
105177
|
-
} else if (inputformat === "RBG") {
|
|
105178
|
-
rTensorPointer = 0;
|
|
105179
|
-
bTensorPointer = stride;
|
|
105180
|
-
gTensorPointer = stride * 2;
|
|
105181
|
-
}
|
|
105182
|
-
image = pixels2DContext.createImageData(width, height);
|
|
105183
|
-
for (let i2 = 0; i2 < height * width; rImagePointer += step, gImagePointer += step, bImagePointer += step, aImagePointer += step, i2++) {
|
|
105184
|
-
image.data[rImagePointer] = (tensor.data[rTensorPointer++] - normBias[0]) * normMean[0];
|
|
105185
|
-
image.data[gImagePointer] = (tensor.data[gTensorPointer++] - normBias[1]) * normMean[1];
|
|
105186
|
-
image.data[bImagePointer] = (tensor.data[bTensorPointer++] - normBias[2]) * normMean[2];
|
|
105187
|
-
image.data[aImagePointer] = aTensorPointer === -1 ? 255 : (tensor.data[aTensorPointer++] - normBias[3]) * normMean[3];
|
|
105188
|
-
}
|
|
105189
|
-
} else {
|
|
105190
|
-
throw new Error("Can not access image data");
|
|
105191
|
-
}
|
|
105192
|
-
return image;
|
|
105193
|
-
};
|
|
105194
|
-
exports.tensorToImageData = tensorToImageData;
|
|
105195
|
-
}
|
|
105196
|
-
});
|
|
105197
|
-
|
|
105198
|
-
// ../../node_modules/.bun/onnxruntime-common@1.26.0/node_modules/onnxruntime-common/dist/cjs/tensor-factory-impl.js
|
|
105199
|
-
var require_tensor_factory_impl = __commonJS({
|
|
105200
|
-
"../../node_modules/.bun/onnxruntime-common@1.26.0/node_modules/onnxruntime-common/dist/cjs/tensor-factory-impl.js"(exports) {
|
|
105201
|
-
"use strict";
|
|
105202
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
105203
|
-
exports.tensorFromPinnedBuffer = exports.tensorFromMLTensor = exports.tensorFromGpuBuffer = exports.tensorFromTexture = exports.tensorFromImage = exports.bufferToTensor = void 0;
|
|
105204
|
-
var tensor_impl_js_1 = require_tensor_impl();
|
|
105205
|
-
var bufferToTensor = (buffer, options) => {
|
|
105206
|
-
if (buffer === void 0) {
|
|
105207
|
-
throw new Error("Image buffer must be defined");
|
|
105208
|
-
}
|
|
105209
|
-
if (options.height === void 0 || options.width === void 0) {
|
|
105210
|
-
throw new Error("Image height and width must be defined");
|
|
105211
|
-
}
|
|
105212
|
-
if (options.tensorLayout === "NHWC") {
|
|
105213
|
-
throw new Error("NHWC Tensor layout is not supported yet");
|
|
105214
|
-
}
|
|
105215
|
-
const { height, width } = options;
|
|
105216
|
-
const norm = options.norm ?? { mean: 255, bias: 0 };
|
|
105217
|
-
let normMean;
|
|
105218
|
-
let normBias;
|
|
105219
|
-
if (typeof norm.mean === "number") {
|
|
105220
|
-
normMean = [norm.mean, norm.mean, norm.mean, norm.mean];
|
|
105221
|
-
} else {
|
|
105222
|
-
normMean = [norm.mean[0], norm.mean[1], norm.mean[2], norm.mean[3] ?? 255];
|
|
105223
|
-
}
|
|
105224
|
-
if (typeof norm.bias === "number") {
|
|
105225
|
-
normBias = [norm.bias, norm.bias, norm.bias, norm.bias];
|
|
105226
|
-
} else {
|
|
105227
|
-
normBias = [norm.bias[0], norm.bias[1], norm.bias[2], norm.bias[3] ?? 0];
|
|
105228
|
-
}
|
|
105229
|
-
const inputformat = options.format !== void 0 ? options.format : "RGBA";
|
|
105230
|
-
const outputformat = options.tensorFormat !== void 0 ? options.tensorFormat !== void 0 ? options.tensorFormat : "RGB" : "RGB";
|
|
105231
|
-
const stride = height * width;
|
|
105232
|
-
const float32Data = outputformat === "RGBA" ? new Float32Array(stride * 4) : new Float32Array(stride * 3);
|
|
105233
|
-
let step = 4, rImagePointer = 0, gImagePointer = 1, bImagePointer = 2, aImagePointer = 3;
|
|
105234
|
-
let rTensorPointer = 0, gTensorPointer = stride, bTensorPointer = stride * 2, aTensorPointer = -1;
|
|
105235
|
-
if (inputformat === "RGB") {
|
|
105236
|
-
step = 3;
|
|
105237
|
-
rImagePointer = 0;
|
|
105238
|
-
gImagePointer = 1;
|
|
105239
|
-
bImagePointer = 2;
|
|
105240
|
-
aImagePointer = -1;
|
|
105241
|
-
}
|
|
105242
|
-
if (outputformat === "RGBA") {
|
|
105243
|
-
aTensorPointer = stride * 3;
|
|
105244
|
-
} else if (outputformat === "RBG") {
|
|
105245
|
-
rTensorPointer = 0;
|
|
105246
|
-
bTensorPointer = stride;
|
|
105247
|
-
gTensorPointer = stride * 2;
|
|
105248
|
-
} else if (outputformat === "BGR") {
|
|
105249
|
-
bTensorPointer = 0;
|
|
105250
|
-
gTensorPointer = stride;
|
|
105251
|
-
rTensorPointer = stride * 2;
|
|
105252
|
-
}
|
|
105253
|
-
for (let i2 = 0; i2 < stride; i2++, rImagePointer += step, bImagePointer += step, gImagePointer += step, aImagePointer += step) {
|
|
105254
|
-
float32Data[rTensorPointer++] = (buffer[rImagePointer] + normBias[0]) / normMean[0];
|
|
105255
|
-
float32Data[gTensorPointer++] = (buffer[gImagePointer] + normBias[1]) / normMean[1];
|
|
105256
|
-
float32Data[bTensorPointer++] = (buffer[bImagePointer] + normBias[2]) / normMean[2];
|
|
105257
|
-
if (aTensorPointer !== -1 && aImagePointer !== -1) {
|
|
105258
|
-
float32Data[aTensorPointer++] = (buffer[aImagePointer] + normBias[3]) / normMean[3];
|
|
105259
|
-
}
|
|
105260
|
-
}
|
|
105261
|
-
const outputTensor = outputformat === "RGBA" ? new tensor_impl_js_1.Tensor("float32", float32Data, [1, 4, height, width]) : new tensor_impl_js_1.Tensor("float32", float32Data, [1, 3, height, width]);
|
|
105262
|
-
return outputTensor;
|
|
105263
|
-
};
|
|
105264
|
-
exports.bufferToTensor = bufferToTensor;
|
|
105265
|
-
var tensorFromImage = async (image, options) => {
|
|
105266
|
-
const isHTMLImageEle = typeof HTMLImageElement !== "undefined" && image instanceof HTMLImageElement;
|
|
105267
|
-
const isImageDataEle = typeof ImageData !== "undefined" && image instanceof ImageData;
|
|
105268
|
-
const isImageBitmap = typeof ImageBitmap !== "undefined" && image instanceof ImageBitmap;
|
|
105269
|
-
const isString = typeof image === "string";
|
|
105270
|
-
let data2;
|
|
105271
|
-
let bufferToTensorOptions = options ?? {};
|
|
105272
|
-
const createCanvas2 = () => {
|
|
105273
|
-
if (typeof document !== "undefined") {
|
|
105274
|
-
return document.createElement("canvas");
|
|
105275
|
-
} else if (typeof OffscreenCanvas !== "undefined") {
|
|
105276
|
-
return new OffscreenCanvas(1, 1);
|
|
105277
|
-
} else {
|
|
105278
|
-
throw new Error("Canvas is not supported");
|
|
105279
|
-
}
|
|
105280
|
-
};
|
|
105281
|
-
const createCanvasContext = (canvas) => {
|
|
105282
|
-
if (typeof HTMLCanvasElement !== "undefined" && canvas instanceof HTMLCanvasElement) {
|
|
105283
|
-
return canvas.getContext("2d");
|
|
105284
|
-
} else if (canvas instanceof OffscreenCanvas) {
|
|
105285
|
-
return canvas.getContext("2d");
|
|
105286
|
-
} else {
|
|
105287
|
-
return null;
|
|
105288
|
-
}
|
|
105289
|
-
};
|
|
105290
|
-
if (isHTMLImageEle) {
|
|
105291
|
-
const canvas = createCanvas2();
|
|
105292
|
-
canvas.width = image.width;
|
|
105293
|
-
canvas.height = image.height;
|
|
105294
|
-
const pixels2DContext = createCanvasContext(canvas);
|
|
105295
|
-
if (pixels2DContext != null) {
|
|
105296
|
-
let height = image.height;
|
|
105297
|
-
let width = image.width;
|
|
105298
|
-
if (options !== void 0 && options.resizedHeight !== void 0 && options.resizedWidth !== void 0) {
|
|
105299
|
-
height = options.resizedHeight;
|
|
105300
|
-
width = options.resizedWidth;
|
|
105301
|
-
}
|
|
105302
|
-
if (options !== void 0) {
|
|
105303
|
-
bufferToTensorOptions = options;
|
|
105304
|
-
if (options.tensorFormat !== void 0) {
|
|
105305
|
-
throw new Error("Image input config format must be RGBA for HTMLImageElement");
|
|
105306
|
-
} else {
|
|
105307
|
-
bufferToTensorOptions.tensorFormat = "RGBA";
|
|
105308
|
-
}
|
|
105309
|
-
bufferToTensorOptions.height = height;
|
|
105310
|
-
bufferToTensorOptions.width = width;
|
|
105311
|
-
} else {
|
|
105312
|
-
bufferToTensorOptions.tensorFormat = "RGBA";
|
|
105313
|
-
bufferToTensorOptions.height = height;
|
|
105314
|
-
bufferToTensorOptions.width = width;
|
|
105315
|
-
}
|
|
105316
|
-
pixels2DContext.drawImage(image, 0, 0);
|
|
105317
|
-
data2 = pixels2DContext.getImageData(0, 0, width, height).data;
|
|
105318
|
-
} else {
|
|
105319
|
-
throw new Error("Can not access image data");
|
|
105320
|
-
}
|
|
105321
|
-
} else if (isImageDataEle) {
|
|
105322
|
-
let height;
|
|
105323
|
-
let width;
|
|
105324
|
-
if (options !== void 0 && options.resizedWidth !== void 0 && options.resizedHeight !== void 0) {
|
|
105325
|
-
height = options.resizedHeight;
|
|
105326
|
-
width = options.resizedWidth;
|
|
105327
|
-
} else {
|
|
105328
|
-
height = image.height;
|
|
105329
|
-
width = image.width;
|
|
105330
|
-
}
|
|
105331
|
-
if (options !== void 0) {
|
|
105332
|
-
bufferToTensorOptions = options;
|
|
105333
|
-
}
|
|
105334
|
-
bufferToTensorOptions.format = "RGBA";
|
|
105335
|
-
bufferToTensorOptions.height = height;
|
|
105336
|
-
bufferToTensorOptions.width = width;
|
|
105337
|
-
if (options !== void 0) {
|
|
105338
|
-
const tempCanvas = createCanvas2();
|
|
105339
|
-
tempCanvas.width = width;
|
|
105340
|
-
tempCanvas.height = height;
|
|
105341
|
-
const pixels2DContext = createCanvasContext(tempCanvas);
|
|
105342
|
-
if (pixels2DContext != null) {
|
|
105343
|
-
pixels2DContext.putImageData(image, 0, 0);
|
|
105344
|
-
data2 = pixels2DContext.getImageData(0, 0, width, height).data;
|
|
105345
|
-
} else {
|
|
105346
|
-
throw new Error("Can not access image data");
|
|
105347
|
-
}
|
|
105348
|
-
} else {
|
|
105349
|
-
data2 = image.data;
|
|
105350
|
-
}
|
|
105351
|
-
} else if (isImageBitmap) {
|
|
105352
|
-
if (options === void 0) {
|
|
105353
|
-
throw new Error("Please provide image config with format for Imagebitmap");
|
|
105354
|
-
}
|
|
105355
|
-
const canvas = createCanvas2();
|
|
105356
|
-
canvas.width = image.width;
|
|
105357
|
-
canvas.height = image.height;
|
|
105358
|
-
const pixels2DContext = createCanvasContext(canvas);
|
|
105359
|
-
if (pixels2DContext != null) {
|
|
105360
|
-
const height = image.height;
|
|
105361
|
-
const width = image.width;
|
|
105362
|
-
pixels2DContext.drawImage(image, 0, 0, width, height);
|
|
105363
|
-
data2 = pixels2DContext.getImageData(0, 0, width, height).data;
|
|
105364
|
-
bufferToTensorOptions.height = height;
|
|
105365
|
-
bufferToTensorOptions.width = width;
|
|
105366
|
-
return (0, exports.bufferToTensor)(data2, bufferToTensorOptions);
|
|
105367
|
-
} else {
|
|
105368
|
-
throw new Error("Can not access image data");
|
|
105369
|
-
}
|
|
105370
|
-
} else if (isString) {
|
|
105371
|
-
return new Promise((resolve56, reject) => {
|
|
105372
|
-
const canvas = createCanvas2();
|
|
105373
|
-
const context = createCanvasContext(canvas);
|
|
105374
|
-
if (!image || !context) {
|
|
105375
|
-
return reject();
|
|
105376
|
-
}
|
|
105377
|
-
const newImage = new Image();
|
|
105378
|
-
newImage.crossOrigin = "Anonymous";
|
|
105379
|
-
newImage.src = image;
|
|
105380
|
-
newImage.onload = () => {
|
|
105381
|
-
canvas.width = newImage.width;
|
|
105382
|
-
canvas.height = newImage.height;
|
|
105383
|
-
context.drawImage(newImage, 0, 0, canvas.width, canvas.height);
|
|
105384
|
-
const img = context.getImageData(0, 0, canvas.width, canvas.height);
|
|
105385
|
-
bufferToTensorOptions.height = canvas.height;
|
|
105386
|
-
bufferToTensorOptions.width = canvas.width;
|
|
105387
|
-
resolve56((0, exports.bufferToTensor)(img.data, bufferToTensorOptions));
|
|
105388
|
-
};
|
|
105389
|
-
});
|
|
105390
|
-
} else {
|
|
105391
|
-
throw new Error("Input data provided is not supported - aborted tensor creation");
|
|
105392
|
-
}
|
|
105393
|
-
if (data2 !== void 0) {
|
|
105394
|
-
return (0, exports.bufferToTensor)(data2, bufferToTensorOptions);
|
|
105395
|
-
} else {
|
|
105396
|
-
throw new Error("Input data provided is not supported - aborted tensor creation");
|
|
105397
|
-
}
|
|
105398
|
-
};
|
|
105399
|
-
exports.tensorFromImage = tensorFromImage;
|
|
105400
|
-
var tensorFromTexture = (texture, options) => {
|
|
105401
|
-
const { width, height, download, dispose } = options;
|
|
105402
|
-
const dims = [1, height, width, 4];
|
|
105403
|
-
return new tensor_impl_js_1.Tensor({ location: "texture", type: "float32", texture, dims, download, dispose });
|
|
105404
|
-
};
|
|
105405
|
-
exports.tensorFromTexture = tensorFromTexture;
|
|
105406
|
-
var tensorFromGpuBuffer = (gpuBuffer, options) => {
|
|
105407
|
-
const { dataType, dims, download, dispose } = options;
|
|
105408
|
-
return new tensor_impl_js_1.Tensor({ location: "gpu-buffer", type: dataType ?? "float32", gpuBuffer, dims, download, dispose });
|
|
105409
|
-
};
|
|
105410
|
-
exports.tensorFromGpuBuffer = tensorFromGpuBuffer;
|
|
105411
|
-
var tensorFromMLTensor = (mlTensor, options) => {
|
|
105412
|
-
const { dataType, dims, download, dispose } = options;
|
|
105413
|
-
return new tensor_impl_js_1.Tensor({ location: "ml-tensor", type: dataType ?? "float32", mlTensor, dims, download, dispose });
|
|
105414
|
-
};
|
|
105415
|
-
exports.tensorFromMLTensor = tensorFromMLTensor;
|
|
105416
|
-
var tensorFromPinnedBuffer = (type, buffer, dims) => new tensor_impl_js_1.Tensor({ location: "cpu-pinned", type, data: buffer, dims: dims ?? [buffer.length] });
|
|
105417
|
-
exports.tensorFromPinnedBuffer = tensorFromPinnedBuffer;
|
|
105418
|
-
}
|
|
105419
|
-
});
|
|
105420
|
-
|
|
105421
|
-
// ../../node_modules/.bun/onnxruntime-common@1.26.0/node_modules/onnxruntime-common/dist/cjs/tensor-impl-type-mapping.js
|
|
105422
|
-
var require_tensor_impl_type_mapping = __commonJS({
|
|
105423
|
-
"../../node_modules/.bun/onnxruntime-common@1.26.0/node_modules/onnxruntime-common/dist/cjs/tensor-impl-type-mapping.js"(exports) {
|
|
105424
|
-
"use strict";
|
|
105425
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
105426
|
-
exports.checkTypedArray = exports.NUMERIC_TENSOR_TYPEDARRAY_TO_TYPE_MAP = exports.NUMERIC_TENSOR_TYPE_TO_TYPEDARRAY_MAP = void 0;
|
|
105427
|
-
exports.NUMERIC_TENSOR_TYPE_TO_TYPEDARRAY_MAP = /* @__PURE__ */ new Map([
|
|
105428
|
-
["float32", Float32Array],
|
|
105429
|
-
["uint8", Uint8Array],
|
|
105430
|
-
["int8", Int8Array],
|
|
105431
|
-
["uint16", Uint16Array],
|
|
105432
|
-
["int16", Int16Array],
|
|
105433
|
-
["int32", Int32Array],
|
|
105434
|
-
["bool", Uint8Array],
|
|
105435
|
-
["float64", Float64Array],
|
|
105436
|
-
["uint32", Uint32Array],
|
|
105437
|
-
["int4", Uint8Array],
|
|
105438
|
-
["uint4", Uint8Array]
|
|
105439
|
-
]);
|
|
105440
|
-
exports.NUMERIC_TENSOR_TYPEDARRAY_TO_TYPE_MAP = /* @__PURE__ */ new Map([
|
|
105441
|
-
[Float32Array, "float32"],
|
|
105442
|
-
[Uint8Array, "uint8"],
|
|
105443
|
-
[Int8Array, "int8"],
|
|
105444
|
-
[Uint16Array, "uint16"],
|
|
105445
|
-
[Int16Array, "int16"],
|
|
105446
|
-
[Int32Array, "int32"],
|
|
105447
|
-
[Float64Array, "float64"],
|
|
105448
|
-
[Uint32Array, "uint32"]
|
|
105449
|
-
]);
|
|
105450
|
-
var isTypedArrayChecked = false;
|
|
105451
|
-
var checkTypedArray = () => {
|
|
105452
|
-
if (!isTypedArrayChecked) {
|
|
105453
|
-
isTypedArrayChecked = true;
|
|
105454
|
-
const isBigInt64ArrayAvailable = typeof BigInt64Array !== "undefined" && BigInt64Array.from;
|
|
105455
|
-
const isBigUint64ArrayAvailable = typeof BigUint64Array !== "undefined" && BigUint64Array.from;
|
|
105456
|
-
const Float16Array = globalThis.Float16Array;
|
|
105457
|
-
const isFloat16ArrayAvailable = typeof Float16Array !== "undefined" && Float16Array.from;
|
|
105458
|
-
if (isBigInt64ArrayAvailable) {
|
|
105459
|
-
exports.NUMERIC_TENSOR_TYPE_TO_TYPEDARRAY_MAP.set("int64", BigInt64Array);
|
|
105460
|
-
exports.NUMERIC_TENSOR_TYPEDARRAY_TO_TYPE_MAP.set(BigInt64Array, "int64");
|
|
105461
|
-
}
|
|
105462
|
-
if (isBigUint64ArrayAvailable) {
|
|
105463
|
-
exports.NUMERIC_TENSOR_TYPE_TO_TYPEDARRAY_MAP.set("uint64", BigUint64Array);
|
|
105464
|
-
exports.NUMERIC_TENSOR_TYPEDARRAY_TO_TYPE_MAP.set(BigUint64Array, "uint64");
|
|
105465
|
-
}
|
|
105466
|
-
if (isFloat16ArrayAvailable) {
|
|
105467
|
-
exports.NUMERIC_TENSOR_TYPE_TO_TYPEDARRAY_MAP.set("float16", Float16Array);
|
|
105468
|
-
exports.NUMERIC_TENSOR_TYPEDARRAY_TO_TYPE_MAP.set(Float16Array, "float16");
|
|
105469
|
-
} else {
|
|
105470
|
-
exports.NUMERIC_TENSOR_TYPE_TO_TYPEDARRAY_MAP.set("float16", Uint16Array);
|
|
105471
|
-
}
|
|
105472
|
-
}
|
|
105473
|
-
};
|
|
105474
|
-
exports.checkTypedArray = checkTypedArray;
|
|
105475
|
-
}
|
|
105476
|
-
});
|
|
105477
|
-
|
|
105478
|
-
// ../../node_modules/.bun/onnxruntime-common@1.26.0/node_modules/onnxruntime-common/dist/cjs/tensor-utils-impl.js
|
|
105479
|
-
var require_tensor_utils_impl = __commonJS({
|
|
105480
|
-
"../../node_modules/.bun/onnxruntime-common@1.26.0/node_modules/onnxruntime-common/dist/cjs/tensor-utils-impl.js"(exports) {
|
|
105481
|
-
"use strict";
|
|
105482
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
105483
|
-
exports.tensorReshape = exports.calculateSize = void 0;
|
|
105484
|
-
var tensor_impl_js_1 = require_tensor_impl();
|
|
105485
|
-
var calculateSize = (dims) => {
|
|
105486
|
-
let size = 1;
|
|
105487
|
-
for (let i2 = 0; i2 < dims.length; i2++) {
|
|
105488
|
-
const dim = dims[i2];
|
|
105489
|
-
if (typeof dim !== "number" || !Number.isSafeInteger(dim)) {
|
|
105490
|
-
throw new TypeError(`dims[${i2}] must be an integer, got: ${dim}`);
|
|
105491
|
-
}
|
|
105492
|
-
if (dim < 0) {
|
|
105493
|
-
throw new RangeError(`dims[${i2}] must be a non-negative integer, got: ${dim}`);
|
|
105494
|
-
}
|
|
105495
|
-
size *= dim;
|
|
105496
|
-
}
|
|
105497
|
-
return size;
|
|
105498
|
-
};
|
|
105499
|
-
exports.calculateSize = calculateSize;
|
|
105500
|
-
var tensorReshape = (tensor, dims) => {
|
|
105501
|
-
switch (tensor.location) {
|
|
105502
|
-
case "cpu":
|
|
105503
|
-
return new tensor_impl_js_1.Tensor(tensor.type, tensor.data, dims);
|
|
105504
|
-
case "cpu-pinned":
|
|
105505
|
-
return new tensor_impl_js_1.Tensor({
|
|
105506
|
-
location: "cpu-pinned",
|
|
105507
|
-
data: tensor.data,
|
|
105508
|
-
type: tensor.type,
|
|
105509
|
-
dims
|
|
105510
|
-
});
|
|
105511
|
-
case "texture":
|
|
105512
|
-
return new tensor_impl_js_1.Tensor({
|
|
105513
|
-
location: "texture",
|
|
105514
|
-
texture: tensor.texture,
|
|
105515
|
-
type: tensor.type,
|
|
105516
|
-
dims
|
|
105517
|
-
});
|
|
105518
|
-
case "gpu-buffer":
|
|
105519
|
-
return new tensor_impl_js_1.Tensor({
|
|
105520
|
-
location: "gpu-buffer",
|
|
105521
|
-
gpuBuffer: tensor.gpuBuffer,
|
|
105522
|
-
type: tensor.type,
|
|
105523
|
-
dims
|
|
105524
|
-
});
|
|
105525
|
-
case "ml-tensor":
|
|
105526
|
-
return new tensor_impl_js_1.Tensor({
|
|
105527
|
-
location: "ml-tensor",
|
|
105528
|
-
mlTensor: tensor.mlTensor,
|
|
105529
|
-
type: tensor.type,
|
|
105530
|
-
dims
|
|
105531
|
-
});
|
|
105532
|
-
default:
|
|
105533
|
-
throw new Error(`tensorReshape: tensor location ${tensor.location} is not supported`);
|
|
105534
|
-
}
|
|
105535
|
-
};
|
|
105536
|
-
exports.tensorReshape = tensorReshape;
|
|
105537
|
-
}
|
|
105538
|
-
});
|
|
105539
|
-
|
|
105540
|
-
// ../../node_modules/.bun/onnxruntime-common@1.26.0/node_modules/onnxruntime-common/dist/cjs/tensor-impl.js
|
|
105541
|
-
var require_tensor_impl = __commonJS({
|
|
105542
|
-
"../../node_modules/.bun/onnxruntime-common@1.26.0/node_modules/onnxruntime-common/dist/cjs/tensor-impl.js"(exports) {
|
|
105543
|
-
"use strict";
|
|
105544
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
105545
|
-
exports.Tensor = void 0;
|
|
105546
|
-
var tensor_conversion_impl_js_1 = require_tensor_conversion_impl();
|
|
105547
|
-
var tensor_factory_impl_js_1 = require_tensor_factory_impl();
|
|
105548
|
-
var tensor_impl_type_mapping_js_1 = require_tensor_impl_type_mapping();
|
|
105549
|
-
var tensor_utils_impl_js_1 = require_tensor_utils_impl();
|
|
105550
|
-
var Tensor = class {
|
|
105551
|
-
/**
|
|
105552
|
-
* implementation.
|
|
105553
|
-
*/
|
|
105554
|
-
constructor(arg0, arg1, arg2) {
|
|
105555
|
-
(0, tensor_impl_type_mapping_js_1.checkTypedArray)();
|
|
105556
|
-
let type;
|
|
105557
|
-
let dims;
|
|
105558
|
-
if (typeof arg0 === "object" && "location" in arg0) {
|
|
105559
|
-
this.dataLocation = arg0.location;
|
|
105560
|
-
type = arg0.type;
|
|
105561
|
-
dims = arg0.dims;
|
|
105562
|
-
switch (arg0.location) {
|
|
105563
|
-
case "cpu-pinned": {
|
|
105564
|
-
const expectedTypedArrayConstructor = tensor_impl_type_mapping_js_1.NUMERIC_TENSOR_TYPE_TO_TYPEDARRAY_MAP.get(type);
|
|
105565
|
-
if (!expectedTypedArrayConstructor) {
|
|
105566
|
-
throw new TypeError(`unsupported type "${type}" to create tensor from pinned buffer`);
|
|
105567
|
-
}
|
|
105568
|
-
if (!(arg0.data instanceof expectedTypedArrayConstructor)) {
|
|
105569
|
-
throw new TypeError(`buffer should be of type ${expectedTypedArrayConstructor.name}`);
|
|
105570
|
-
}
|
|
105571
|
-
this.cpuData = arg0.data;
|
|
105572
|
-
break;
|
|
105573
|
-
}
|
|
105574
|
-
case "texture": {
|
|
105575
|
-
if (type !== "float32") {
|
|
105576
|
-
throw new TypeError(`unsupported type "${type}" to create tensor from texture`);
|
|
105577
|
-
}
|
|
105578
|
-
this.gpuTextureData = arg0.texture;
|
|
105579
|
-
this.downloader = arg0.download;
|
|
105580
|
-
this.disposer = arg0.dispose;
|
|
105581
|
-
break;
|
|
105582
|
-
}
|
|
105583
|
-
case "gpu-buffer": {
|
|
105584
|
-
if (type !== "float32" && type !== "float16" && type !== "int32" && type !== "int64" && type !== "uint32" && type !== "uint8" && type !== "bool" && type !== "uint4" && type !== "int4") {
|
|
105585
|
-
throw new TypeError(`unsupported type "${type}" to create tensor from gpu buffer`);
|
|
105586
|
-
}
|
|
105587
|
-
this.gpuBufferData = arg0.gpuBuffer;
|
|
105588
|
-
this.downloader = arg0.download;
|
|
105589
|
-
this.disposer = arg0.dispose;
|
|
105590
|
-
break;
|
|
105591
|
-
}
|
|
105592
|
-
case "ml-tensor": {
|
|
105593
|
-
if (type !== "float32" && type !== "float16" && type !== "int32" && type !== "int64" && type !== "uint32" && type !== "uint64" && type !== "int8" && type !== "uint8" && type !== "bool" && type !== "uint4" && type !== "int4") {
|
|
105594
|
-
throw new TypeError(`unsupported type "${type}" to create tensor from MLTensor`);
|
|
105595
|
-
}
|
|
105596
|
-
this.mlTensorData = arg0.mlTensor;
|
|
105597
|
-
this.downloader = arg0.download;
|
|
105598
|
-
this.disposer = arg0.dispose;
|
|
105599
|
-
break;
|
|
105600
|
-
}
|
|
105601
|
-
default:
|
|
105602
|
-
throw new Error(`Tensor constructor: unsupported location '${this.dataLocation}'`);
|
|
105603
|
-
}
|
|
105604
|
-
} else {
|
|
105605
|
-
let data2;
|
|
105606
|
-
let maybeDims;
|
|
105607
|
-
if (typeof arg0 === "string") {
|
|
105608
|
-
type = arg0;
|
|
105609
|
-
maybeDims = arg2;
|
|
105610
|
-
if (arg0 === "string") {
|
|
105611
|
-
if (!Array.isArray(arg1)) {
|
|
105612
|
-
throw new TypeError("A string tensor's data must be a string array.");
|
|
105613
|
-
}
|
|
105614
|
-
data2 = arg1;
|
|
105615
|
-
} else {
|
|
105616
|
-
const typedArrayConstructor = tensor_impl_type_mapping_js_1.NUMERIC_TENSOR_TYPE_TO_TYPEDARRAY_MAP.get(arg0);
|
|
105617
|
-
if (typedArrayConstructor === void 0) {
|
|
105618
|
-
throw new TypeError(`Unsupported tensor type: ${arg0}.`);
|
|
105619
|
-
}
|
|
105620
|
-
if (Array.isArray(arg1)) {
|
|
105621
|
-
if (arg0 === "float16" && typedArrayConstructor === Uint16Array || arg0 === "uint4" || arg0 === "int4") {
|
|
105622
|
-
throw new TypeError(`Creating a ${arg0} tensor from number array is not supported. Please use ${typedArrayConstructor.name} as data.`);
|
|
105623
|
-
} else if (arg0 === "uint64" || arg0 === "int64") {
|
|
105624
|
-
data2 = typedArrayConstructor.from(arg1, BigInt);
|
|
105625
|
-
} else {
|
|
105626
|
-
data2 = typedArrayConstructor.from(arg1);
|
|
105627
|
-
}
|
|
105628
|
-
} else if (arg1 instanceof typedArrayConstructor) {
|
|
105629
|
-
data2 = arg1;
|
|
105630
|
-
} else if (arg1 instanceof Uint8ClampedArray) {
|
|
105631
|
-
if (arg0 === "uint8") {
|
|
105632
|
-
data2 = Uint8Array.from(arg1);
|
|
105633
|
-
} else {
|
|
105634
|
-
throw new TypeError(`A Uint8ClampedArray tensor's data must be type of uint8`);
|
|
105635
|
-
}
|
|
105636
|
-
} else if (arg0 === "float16" && arg1 instanceof Uint16Array && typedArrayConstructor !== Uint16Array) {
|
|
105637
|
-
data2 = new globalThis.Float16Array(arg1.buffer, arg1.byteOffset, arg1.length);
|
|
105638
|
-
} else {
|
|
105639
|
-
throw new TypeError(`A ${type} tensor's data must be type of ${typedArrayConstructor}`);
|
|
105640
|
-
}
|
|
105641
|
-
}
|
|
105642
|
-
} else {
|
|
105643
|
-
maybeDims = arg1;
|
|
105644
|
-
if (Array.isArray(arg0)) {
|
|
105645
|
-
if (arg0.length === 0) {
|
|
105646
|
-
throw new TypeError("Tensor type cannot be inferred from an empty array.");
|
|
105647
|
-
}
|
|
105648
|
-
const firstElementType = typeof arg0[0];
|
|
105649
|
-
if (firstElementType === "string") {
|
|
105650
|
-
type = "string";
|
|
105651
|
-
data2 = arg0;
|
|
105652
|
-
} else if (firstElementType === "boolean") {
|
|
105653
|
-
type = "bool";
|
|
105654
|
-
data2 = Uint8Array.from(arg0);
|
|
105655
|
-
} else {
|
|
105656
|
-
throw new TypeError(`Invalid element type of data array: ${firstElementType}.`);
|
|
105657
|
-
}
|
|
105658
|
-
} else if (arg0 instanceof Uint8ClampedArray) {
|
|
105659
|
-
type = "uint8";
|
|
105660
|
-
data2 = Uint8Array.from(arg0);
|
|
105661
|
-
} else {
|
|
105662
|
-
const mappedType = tensor_impl_type_mapping_js_1.NUMERIC_TENSOR_TYPEDARRAY_TO_TYPE_MAP.get(arg0.constructor);
|
|
105663
|
-
if (mappedType === void 0) {
|
|
105664
|
-
throw new TypeError(`Unsupported type for tensor data: ${arg0.constructor}.`);
|
|
105665
|
-
}
|
|
105666
|
-
type = mappedType;
|
|
105667
|
-
data2 = arg0;
|
|
105668
|
-
}
|
|
105669
|
-
}
|
|
105670
|
-
if (maybeDims === void 0) {
|
|
105671
|
-
maybeDims = [data2.length];
|
|
105672
|
-
} else if (!Array.isArray(maybeDims)) {
|
|
105673
|
-
throw new TypeError("A tensor's dims must be a number array");
|
|
105674
|
-
}
|
|
105675
|
-
dims = maybeDims;
|
|
105676
|
-
this.cpuData = data2;
|
|
105677
|
-
this.dataLocation = "cpu";
|
|
105678
|
-
}
|
|
105679
|
-
const size = (0, tensor_utils_impl_js_1.calculateSize)(dims);
|
|
105680
|
-
if (this.cpuData && size !== this.cpuData.length) {
|
|
105681
|
-
if ((type === "uint4" || type === "int4") && Math.ceil(size / 2) === this.cpuData.length) {
|
|
105682
|
-
} else {
|
|
105683
|
-
throw new Error(`Tensor's size(${size}) does not match data length(${this.cpuData.length}).`);
|
|
105684
|
-
}
|
|
105685
|
-
}
|
|
105686
|
-
this.type = type;
|
|
105687
|
-
this.dims = dims;
|
|
105688
|
-
this.size = size;
|
|
105689
|
-
}
|
|
105690
|
-
// #endregion
|
|
105691
|
-
// #region factory
|
|
105692
|
-
static async fromImage(image, options) {
|
|
105693
|
-
return (0, tensor_factory_impl_js_1.tensorFromImage)(image, options);
|
|
105694
|
-
}
|
|
105695
|
-
static fromTexture(texture, options) {
|
|
105696
|
-
return (0, tensor_factory_impl_js_1.tensorFromTexture)(texture, options);
|
|
105697
|
-
}
|
|
105698
|
-
static fromGpuBuffer(gpuBuffer, options) {
|
|
105699
|
-
return (0, tensor_factory_impl_js_1.tensorFromGpuBuffer)(gpuBuffer, options);
|
|
105700
|
-
}
|
|
105701
|
-
static fromMLTensor(mlTensor, options) {
|
|
105702
|
-
return (0, tensor_factory_impl_js_1.tensorFromMLTensor)(mlTensor, options);
|
|
105703
|
-
}
|
|
105704
|
-
static fromPinnedBuffer(type, buffer, dims) {
|
|
105705
|
-
return (0, tensor_factory_impl_js_1.tensorFromPinnedBuffer)(type, buffer, dims);
|
|
105706
|
-
}
|
|
105707
|
-
// #endregion
|
|
105708
|
-
// #region conversions
|
|
105709
|
-
toDataURL(options) {
|
|
105710
|
-
return (0, tensor_conversion_impl_js_1.tensorToDataURL)(this, options);
|
|
105711
|
-
}
|
|
105712
|
-
toImageData(options) {
|
|
105713
|
-
return (0, tensor_conversion_impl_js_1.tensorToImageData)(this, options);
|
|
105714
|
-
}
|
|
105715
|
-
// #endregion
|
|
105716
|
-
// #region properties
|
|
105717
|
-
get data() {
|
|
105718
|
-
this.ensureValid();
|
|
105719
|
-
if (!this.cpuData) {
|
|
105720
|
-
throw new Error("The data is not on CPU. Use `getData()` to download GPU data to CPU, or use `texture` or `gpuBuffer` property to access the GPU data directly.");
|
|
105721
|
-
}
|
|
105722
|
-
return this.cpuData;
|
|
105723
|
-
}
|
|
105724
|
-
get location() {
|
|
105725
|
-
return this.dataLocation;
|
|
105726
|
-
}
|
|
105727
|
-
get texture() {
|
|
105728
|
-
this.ensureValid();
|
|
105729
|
-
if (!this.gpuTextureData) {
|
|
105730
|
-
throw new Error("The data is not stored as a WebGL texture.");
|
|
105731
|
-
}
|
|
105732
|
-
return this.gpuTextureData;
|
|
105733
|
-
}
|
|
105734
|
-
get gpuBuffer() {
|
|
105735
|
-
this.ensureValid();
|
|
105736
|
-
if (!this.gpuBufferData) {
|
|
105737
|
-
throw new Error("The data is not stored as a WebGPU buffer.");
|
|
105738
|
-
}
|
|
105739
|
-
return this.gpuBufferData;
|
|
105740
|
-
}
|
|
105741
|
-
get mlTensor() {
|
|
105742
|
-
this.ensureValid();
|
|
105743
|
-
if (!this.mlTensorData) {
|
|
105744
|
-
throw new Error("The data is not stored as a WebNN MLTensor.");
|
|
105745
|
-
}
|
|
105746
|
-
return this.mlTensorData;
|
|
105747
|
-
}
|
|
105748
|
-
// #endregion
|
|
105749
|
-
// #region methods
|
|
105750
|
-
async getData(releaseData) {
|
|
105751
|
-
this.ensureValid();
|
|
105752
|
-
switch (this.dataLocation) {
|
|
105753
|
-
case "cpu":
|
|
105754
|
-
case "cpu-pinned":
|
|
105755
|
-
return this.data;
|
|
105756
|
-
case "texture":
|
|
105757
|
-
case "gpu-buffer":
|
|
105758
|
-
case "ml-tensor": {
|
|
105759
|
-
if (!this.downloader) {
|
|
105760
|
-
throw new Error("The current tensor is not created with a specified data downloader.");
|
|
105761
|
-
}
|
|
105762
|
-
if (this.isDownloading) {
|
|
105763
|
-
throw new Error("The current tensor is being downloaded.");
|
|
105764
|
-
}
|
|
105765
|
-
try {
|
|
105766
|
-
this.isDownloading = true;
|
|
105767
|
-
const data2 = await this.downloader();
|
|
105768
|
-
this.downloader = void 0;
|
|
105769
|
-
this.dataLocation = "cpu";
|
|
105770
|
-
this.cpuData = data2;
|
|
105771
|
-
if (releaseData && this.disposer) {
|
|
105772
|
-
this.disposer();
|
|
105773
|
-
this.disposer = void 0;
|
|
105774
|
-
}
|
|
105775
|
-
return data2;
|
|
105776
|
-
} finally {
|
|
105777
|
-
this.isDownloading = false;
|
|
105778
|
-
}
|
|
105779
|
-
}
|
|
105780
|
-
default:
|
|
105781
|
-
throw new Error(`cannot get data from location: ${this.dataLocation}`);
|
|
105782
|
-
}
|
|
105783
|
-
}
|
|
105784
|
-
dispose() {
|
|
105785
|
-
if (this.isDownloading) {
|
|
105786
|
-
throw new Error("The current tensor is being downloaded.");
|
|
105787
|
-
}
|
|
105788
|
-
if (this.disposer) {
|
|
105789
|
-
this.disposer();
|
|
105790
|
-
this.disposer = void 0;
|
|
105791
|
-
}
|
|
105792
|
-
this.cpuData = void 0;
|
|
105793
|
-
this.gpuTextureData = void 0;
|
|
105794
|
-
this.gpuBufferData = void 0;
|
|
105795
|
-
this.mlTensorData = void 0;
|
|
105796
|
-
this.downloader = void 0;
|
|
105797
|
-
this.isDownloading = void 0;
|
|
105798
|
-
this.dataLocation = "none";
|
|
105799
|
-
}
|
|
105800
|
-
// #endregion
|
|
105801
|
-
// #region tensor utilities
|
|
105802
|
-
ensureValid() {
|
|
105803
|
-
if (this.dataLocation === "none") {
|
|
105804
|
-
throw new Error("The tensor is disposed.");
|
|
105805
|
-
}
|
|
105806
|
-
}
|
|
105807
|
-
reshape(dims) {
|
|
105808
|
-
this.ensureValid();
|
|
105809
|
-
if (this.downloader || this.disposer) {
|
|
105810
|
-
throw new Error("Cannot reshape a tensor that owns GPU resource.");
|
|
105811
|
-
}
|
|
105812
|
-
return (0, tensor_utils_impl_js_1.tensorReshape)(this, dims);
|
|
105813
|
-
}
|
|
105814
|
-
};
|
|
105815
|
-
exports.Tensor = Tensor;
|
|
105816
|
-
}
|
|
105817
|
-
});
|
|
105818
|
-
|
|
105819
|
-
// ../../node_modules/.bun/onnxruntime-common@1.26.0/node_modules/onnxruntime-common/dist/cjs/tensor.js
|
|
105820
|
-
var require_tensor = __commonJS({
|
|
105821
|
-
"../../node_modules/.bun/onnxruntime-common@1.26.0/node_modules/onnxruntime-common/dist/cjs/tensor.js"(exports) {
|
|
105822
|
-
"use strict";
|
|
105823
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
105824
|
-
exports.Tensor = void 0;
|
|
105825
|
-
var tensor_impl_js_1 = require_tensor_impl();
|
|
105826
|
-
exports.Tensor = tensor_impl_js_1.Tensor;
|
|
105827
|
-
}
|
|
105828
|
-
});
|
|
105829
|
-
|
|
105830
|
-
// ../../node_modules/.bun/onnxruntime-common@1.26.0/node_modules/onnxruntime-common/dist/cjs/trace.js
|
|
105831
|
-
var require_trace = __commonJS({
|
|
105832
|
-
"../../node_modules/.bun/onnxruntime-common@1.26.0/node_modules/onnxruntime-common/dist/cjs/trace.js"(exports) {
|
|
105833
|
-
"use strict";
|
|
105834
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
105835
|
-
exports.TRACE_EVENT_END = exports.TRACE_EVENT_BEGIN = exports.TRACE_FUNC_END = exports.TRACE_FUNC_BEGIN = exports.TRACE = void 0;
|
|
105836
|
-
var env_impl_js_1 = require_env_impl();
|
|
105837
|
-
var TRACE = (deviceType, label2) => {
|
|
105838
|
-
if (typeof env_impl_js_1.env.trace === "undefined" ? !env_impl_js_1.env.wasm.trace : !env_impl_js_1.env.trace) {
|
|
105839
|
-
return;
|
|
105840
|
-
}
|
|
105841
|
-
console.timeStamp(`${deviceType}::ORT::${label2}`);
|
|
105842
|
-
};
|
|
105843
|
-
exports.TRACE = TRACE;
|
|
105844
|
-
var TRACE_FUNC = (msg, extraMsg) => {
|
|
105845
|
-
const stack = new Error().stack?.split(/\r\n|\r|\n/g) || [];
|
|
105846
|
-
let hasTraceFunc = false;
|
|
105847
|
-
for (let i2 = 0; i2 < stack.length; i2++) {
|
|
105848
|
-
if (hasTraceFunc && !stack[i2].includes("TRACE_FUNC")) {
|
|
105849
|
-
let label2 = `FUNC_${msg}::${stack[i2].trim().split(" ")[1]}`;
|
|
105850
|
-
if (extraMsg) {
|
|
105851
|
-
label2 += `::${extraMsg}`;
|
|
105852
|
-
}
|
|
105853
|
-
(0, exports.TRACE)("CPU", label2);
|
|
105854
|
-
return;
|
|
105855
|
-
}
|
|
105856
|
-
if (stack[i2].includes("TRACE_FUNC")) {
|
|
105857
|
-
hasTraceFunc = true;
|
|
105858
|
-
}
|
|
105859
|
-
}
|
|
105860
|
-
};
|
|
105861
|
-
var TRACE_FUNC_BEGIN = (extraMsg) => {
|
|
105862
|
-
if (typeof env_impl_js_1.env.trace === "undefined" ? !env_impl_js_1.env.wasm.trace : !env_impl_js_1.env.trace) {
|
|
105863
|
-
return;
|
|
105864
|
-
}
|
|
105865
|
-
TRACE_FUNC("BEGIN", extraMsg);
|
|
105866
|
-
};
|
|
105867
|
-
exports.TRACE_FUNC_BEGIN = TRACE_FUNC_BEGIN;
|
|
105868
|
-
var TRACE_FUNC_END = (extraMsg) => {
|
|
105869
|
-
if (typeof env_impl_js_1.env.trace === "undefined" ? !env_impl_js_1.env.wasm.trace : !env_impl_js_1.env.trace) {
|
|
105870
|
-
return;
|
|
105871
|
-
}
|
|
105872
|
-
TRACE_FUNC("END", extraMsg);
|
|
105873
|
-
};
|
|
105874
|
-
exports.TRACE_FUNC_END = TRACE_FUNC_END;
|
|
105875
|
-
var TRACE_EVENT_BEGIN = (extraMsg) => {
|
|
105876
|
-
if (typeof env_impl_js_1.env.trace === "undefined" ? !env_impl_js_1.env.wasm.trace : !env_impl_js_1.env.trace) {
|
|
105877
|
-
return;
|
|
105878
|
-
}
|
|
105879
|
-
console.time(`ORT::${extraMsg}`);
|
|
105880
|
-
};
|
|
105881
|
-
exports.TRACE_EVENT_BEGIN = TRACE_EVENT_BEGIN;
|
|
105882
|
-
var TRACE_EVENT_END = (extraMsg) => {
|
|
105883
|
-
if (typeof env_impl_js_1.env.trace === "undefined" ? !env_impl_js_1.env.wasm.trace : !env_impl_js_1.env.trace) {
|
|
105884
|
-
return;
|
|
105885
|
-
}
|
|
105886
|
-
console.timeEnd(`ORT::${extraMsg}`);
|
|
105887
|
-
};
|
|
105888
|
-
exports.TRACE_EVENT_END = TRACE_EVENT_END;
|
|
105889
|
-
}
|
|
105890
|
-
});
|
|
105891
|
-
|
|
105892
|
-
// ../../node_modules/.bun/onnxruntime-common@1.26.0/node_modules/onnxruntime-common/dist/cjs/inference-session-impl.js
|
|
105893
|
-
var require_inference_session_impl = __commonJS({
|
|
105894
|
-
"../../node_modules/.bun/onnxruntime-common@1.26.0/node_modules/onnxruntime-common/dist/cjs/inference-session-impl.js"(exports) {
|
|
105895
|
-
"use strict";
|
|
105896
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
105897
|
-
exports.InferenceSession = void 0;
|
|
105898
|
-
var backend_impl_js_1 = require_backend_impl();
|
|
105899
|
-
var tensor_js_1 = require_tensor();
|
|
105900
|
-
var trace_js_1 = require_trace();
|
|
105901
|
-
var InferenceSession = class _InferenceSession {
|
|
105902
|
-
constructor(handler4) {
|
|
105903
|
-
this.handler = handler4;
|
|
105904
|
-
}
|
|
105905
|
-
async run(feeds, arg1, arg2) {
|
|
105906
|
-
(0, trace_js_1.TRACE_FUNC_BEGIN)();
|
|
105907
|
-
(0, trace_js_1.TRACE_EVENT_BEGIN)("InferenceSession.run");
|
|
105908
|
-
const fetches = {};
|
|
105909
|
-
let options = {};
|
|
105910
|
-
if (typeof feeds !== "object" || feeds === null || feeds instanceof tensor_js_1.Tensor || Array.isArray(feeds)) {
|
|
105911
|
-
throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");
|
|
105912
|
-
}
|
|
105913
|
-
let isFetchesEmpty = true;
|
|
105914
|
-
if (typeof arg1 === "object") {
|
|
105915
|
-
if (arg1 === null) {
|
|
105916
|
-
throw new TypeError("Unexpected argument[1]: cannot be null.");
|
|
105917
|
-
}
|
|
105918
|
-
if (arg1 instanceof tensor_js_1.Tensor) {
|
|
105919
|
-
throw new TypeError("'fetches' cannot be a Tensor");
|
|
105920
|
-
}
|
|
105921
|
-
if (Array.isArray(arg1)) {
|
|
105922
|
-
if (arg1.length === 0) {
|
|
105923
|
-
throw new TypeError("'fetches' cannot be an empty array.");
|
|
105924
|
-
}
|
|
105925
|
-
isFetchesEmpty = false;
|
|
105926
|
-
for (const name of arg1) {
|
|
105927
|
-
if (typeof name !== "string") {
|
|
105928
|
-
throw new TypeError("'fetches' must be a string array or an object.");
|
|
105929
|
-
}
|
|
105930
|
-
if (this.outputNames.indexOf(name) === -1) {
|
|
105931
|
-
throw new RangeError(`'fetches' contains invalid output name: ${name}.`);
|
|
105932
|
-
}
|
|
105933
|
-
fetches[name] = null;
|
|
105934
|
-
}
|
|
105935
|
-
if (typeof arg2 === "object" && arg2 !== null) {
|
|
105936
|
-
options = arg2;
|
|
105937
|
-
} else if (typeof arg2 !== "undefined") {
|
|
105938
|
-
throw new TypeError("'options' must be an object.");
|
|
105939
|
-
}
|
|
105940
|
-
} else {
|
|
105941
|
-
let isFetches = false;
|
|
105942
|
-
const arg1Keys = Object.getOwnPropertyNames(arg1);
|
|
105943
|
-
for (const name of this.outputNames) {
|
|
105944
|
-
if (arg1Keys.indexOf(name) !== -1) {
|
|
105945
|
-
const v2 = arg1[name];
|
|
105946
|
-
if (v2 === null || v2 instanceof tensor_js_1.Tensor) {
|
|
105947
|
-
isFetches = true;
|
|
105948
|
-
isFetchesEmpty = false;
|
|
105949
|
-
fetches[name] = v2;
|
|
105950
|
-
}
|
|
105951
|
-
}
|
|
105952
|
-
}
|
|
105953
|
-
if (isFetches) {
|
|
105954
|
-
if (typeof arg2 === "object" && arg2 !== null) {
|
|
105955
|
-
options = arg2;
|
|
105956
|
-
} else if (typeof arg2 !== "undefined") {
|
|
105957
|
-
throw new TypeError("'options' must be an object.");
|
|
105958
|
-
}
|
|
105959
|
-
} else {
|
|
105960
|
-
options = arg1;
|
|
105961
|
-
}
|
|
105962
|
-
}
|
|
105963
|
-
} else if (typeof arg1 !== "undefined") {
|
|
105964
|
-
throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");
|
|
105965
|
-
}
|
|
105966
|
-
for (const name of this.inputNames) {
|
|
105967
|
-
if (typeof feeds[name] === "undefined") {
|
|
105968
|
-
throw new Error(`input '${name}' is missing in 'feeds'.`);
|
|
105969
|
-
}
|
|
105970
|
-
}
|
|
105971
|
-
if (isFetchesEmpty) {
|
|
105972
|
-
for (const name of this.outputNames) {
|
|
105973
|
-
fetches[name] = null;
|
|
105974
|
-
}
|
|
105975
|
-
}
|
|
105976
|
-
const results = await this.handler.run(feeds, fetches, options);
|
|
105977
|
-
const returnValue = {};
|
|
105978
|
-
for (const key2 in results) {
|
|
105979
|
-
if (Object.hasOwnProperty.call(results, key2)) {
|
|
105980
|
-
const result = results[key2];
|
|
105981
|
-
if (result instanceof tensor_js_1.Tensor) {
|
|
105982
|
-
returnValue[key2] = result;
|
|
105983
|
-
} else {
|
|
105984
|
-
returnValue[key2] = new tensor_js_1.Tensor(result.type, result.data, result.dims);
|
|
105985
|
-
}
|
|
105986
|
-
}
|
|
105987
|
-
}
|
|
105988
|
-
(0, trace_js_1.TRACE_EVENT_END)("InferenceSession.run");
|
|
105989
|
-
(0, trace_js_1.TRACE_FUNC_END)();
|
|
105990
|
-
return returnValue;
|
|
105991
|
-
}
|
|
105992
|
-
async release() {
|
|
105993
|
-
return this.handler.dispose();
|
|
105994
|
-
}
|
|
105995
|
-
static async create(arg0, arg1, arg2, arg3) {
|
|
105996
|
-
(0, trace_js_1.TRACE_FUNC_BEGIN)();
|
|
105997
|
-
(0, trace_js_1.TRACE_EVENT_BEGIN)("InferenceSession.create");
|
|
105998
|
-
let filePathOrUint8Array;
|
|
105999
|
-
let options = {};
|
|
106000
|
-
if (typeof arg0 === "string") {
|
|
106001
|
-
filePathOrUint8Array = arg0;
|
|
106002
|
-
if (typeof arg1 === "object" && arg1 !== null) {
|
|
106003
|
-
options = arg1;
|
|
106004
|
-
} else if (typeof arg1 !== "undefined") {
|
|
106005
|
-
throw new TypeError("'options' must be an object.");
|
|
106006
|
-
}
|
|
106007
|
-
} else if (arg0 instanceof Uint8Array) {
|
|
106008
|
-
filePathOrUint8Array = arg0;
|
|
106009
|
-
if (typeof arg1 === "object" && arg1 !== null) {
|
|
106010
|
-
options = arg1;
|
|
106011
|
-
} else if (typeof arg1 !== "undefined") {
|
|
106012
|
-
throw new TypeError("'options' must be an object.");
|
|
106013
|
-
}
|
|
106014
|
-
} else if (arg0 instanceof ArrayBuffer || typeof SharedArrayBuffer !== "undefined" && arg0 instanceof SharedArrayBuffer) {
|
|
106015
|
-
const buffer = arg0;
|
|
106016
|
-
let byteOffset = 0;
|
|
106017
|
-
let byteLength = arg0.byteLength;
|
|
106018
|
-
if (typeof arg1 === "object" && arg1 !== null) {
|
|
106019
|
-
options = arg1;
|
|
106020
|
-
} else if (typeof arg1 === "number") {
|
|
106021
|
-
byteOffset = arg1;
|
|
106022
|
-
if (!Number.isSafeInteger(byteOffset)) {
|
|
106023
|
-
throw new RangeError("'byteOffset' must be an integer.");
|
|
106024
|
-
}
|
|
106025
|
-
if (byteOffset < 0 || byteOffset >= buffer.byteLength) {
|
|
106026
|
-
throw new RangeError(`'byteOffset' is out of range [0, ${buffer.byteLength}).`);
|
|
106027
|
-
}
|
|
106028
|
-
byteLength = arg0.byteLength - byteOffset;
|
|
106029
|
-
if (typeof arg2 === "number") {
|
|
106030
|
-
byteLength = arg2;
|
|
106031
|
-
if (!Number.isSafeInteger(byteLength)) {
|
|
106032
|
-
throw new RangeError("'byteLength' must be an integer.");
|
|
106033
|
-
}
|
|
106034
|
-
if (byteLength <= 0 || byteOffset + byteLength > buffer.byteLength) {
|
|
106035
|
-
throw new RangeError(`'byteLength' is out of range (0, ${buffer.byteLength - byteOffset}].`);
|
|
106036
|
-
}
|
|
106037
|
-
if (typeof arg3 === "object" && arg3 !== null) {
|
|
106038
|
-
options = arg3;
|
|
106039
|
-
} else if (typeof arg3 !== "undefined") {
|
|
106040
|
-
throw new TypeError("'options' must be an object.");
|
|
106041
|
-
}
|
|
106042
|
-
} else if (typeof arg2 !== "undefined") {
|
|
106043
|
-
throw new TypeError("'byteLength' must be a number.");
|
|
106044
|
-
}
|
|
106045
|
-
} else if (typeof arg1 !== "undefined") {
|
|
106046
|
-
throw new TypeError("'options' must be an object.");
|
|
106047
|
-
}
|
|
106048
|
-
filePathOrUint8Array = new Uint8Array(buffer, byteOffset, byteLength);
|
|
106049
|
-
} else {
|
|
106050
|
-
throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");
|
|
106051
|
-
}
|
|
106052
|
-
const [backend, optionsWithValidatedEPs] = await (0, backend_impl_js_1.resolveBackendAndExecutionProviders)(options);
|
|
106053
|
-
const handler4 = await backend.createInferenceSessionHandler(filePathOrUint8Array, optionsWithValidatedEPs);
|
|
106054
|
-
(0, trace_js_1.TRACE_EVENT_END)("InferenceSession.create");
|
|
106055
|
-
(0, trace_js_1.TRACE_FUNC_END)();
|
|
106056
|
-
return new _InferenceSession(handler4);
|
|
106057
|
-
}
|
|
106058
|
-
startProfiling() {
|
|
106059
|
-
this.handler.startProfiling();
|
|
106060
|
-
}
|
|
106061
|
-
endProfiling() {
|
|
106062
|
-
this.handler.endProfiling();
|
|
106063
|
-
}
|
|
106064
|
-
get inputNames() {
|
|
106065
|
-
return this.handler.inputNames;
|
|
106066
|
-
}
|
|
106067
|
-
get outputNames() {
|
|
106068
|
-
return this.handler.outputNames;
|
|
106069
|
-
}
|
|
106070
|
-
get inputMetadata() {
|
|
106071
|
-
return this.handler.inputMetadata;
|
|
106072
|
-
}
|
|
106073
|
-
get outputMetadata() {
|
|
106074
|
-
return this.handler.outputMetadata;
|
|
106075
|
-
}
|
|
106076
|
-
};
|
|
106077
|
-
exports.InferenceSession = InferenceSession;
|
|
106078
|
-
}
|
|
106079
|
-
});
|
|
106080
|
-
|
|
106081
|
-
// ../../node_modules/.bun/onnxruntime-common@1.26.0/node_modules/onnxruntime-common/dist/cjs/inference-session.js
|
|
106082
|
-
var require_inference_session = __commonJS({
|
|
106083
|
-
"../../node_modules/.bun/onnxruntime-common@1.26.0/node_modules/onnxruntime-common/dist/cjs/inference-session.js"(exports) {
|
|
106084
|
-
"use strict";
|
|
106085
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
106086
|
-
exports.InferenceSession = void 0;
|
|
106087
|
-
var inference_session_impl_js_1 = require_inference_session_impl();
|
|
106088
|
-
exports.InferenceSession = inference_session_impl_js_1.InferenceSession;
|
|
106089
|
-
}
|
|
106090
|
-
});
|
|
106091
|
-
|
|
106092
|
-
// ../../node_modules/.bun/onnxruntime-common@1.26.0/node_modules/onnxruntime-common/dist/cjs/tensor-conversion.js
|
|
106093
|
-
var require_tensor_conversion = __commonJS({
|
|
106094
|
-
"../../node_modules/.bun/onnxruntime-common@1.26.0/node_modules/onnxruntime-common/dist/cjs/tensor-conversion.js"(exports) {
|
|
106095
|
-
"use strict";
|
|
106096
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
106097
|
-
}
|
|
106098
|
-
});
|
|
106099
|
-
|
|
106100
|
-
// ../../node_modules/.bun/onnxruntime-common@1.26.0/node_modules/onnxruntime-common/dist/cjs/tensor-factory.js
|
|
106101
|
-
var require_tensor_factory = __commonJS({
|
|
106102
|
-
"../../node_modules/.bun/onnxruntime-common@1.26.0/node_modules/onnxruntime-common/dist/cjs/tensor-factory.js"(exports) {
|
|
106103
|
-
"use strict";
|
|
106104
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
106105
|
-
}
|
|
106106
|
-
});
|
|
106107
|
-
|
|
106108
|
-
// ../../node_modules/.bun/onnxruntime-common@1.26.0/node_modules/onnxruntime-common/dist/cjs/onnx-model.js
|
|
106109
|
-
var require_onnx_model = __commonJS({
|
|
106110
|
-
"../../node_modules/.bun/onnxruntime-common@1.26.0/node_modules/onnxruntime-common/dist/cjs/onnx-model.js"(exports) {
|
|
106111
|
-
"use strict";
|
|
106112
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
106113
|
-
}
|
|
106114
|
-
});
|
|
106115
|
-
|
|
106116
|
-
// ../../node_modules/.bun/onnxruntime-common@1.26.0/node_modules/onnxruntime-common/dist/cjs/onnx-value.js
|
|
106117
|
-
var require_onnx_value = __commonJS({
|
|
106118
|
-
"../../node_modules/.bun/onnxruntime-common@1.26.0/node_modules/onnxruntime-common/dist/cjs/onnx-value.js"(exports) {
|
|
106119
|
-
"use strict";
|
|
106120
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
106121
|
-
}
|
|
106122
|
-
});
|
|
106123
|
-
|
|
106124
|
-
// ../../node_modules/.bun/onnxruntime-common@1.26.0/node_modules/onnxruntime-common/dist/cjs/index.js
|
|
106125
|
-
var require_cjs = __commonJS({
|
|
106126
|
-
"../../node_modules/.bun/onnxruntime-common@1.26.0/node_modules/onnxruntime-common/dist/cjs/index.js"(exports) {
|
|
106127
|
-
"use strict";
|
|
106128
|
-
var __createBinding2 = exports && exports.__createBinding || (Object.create ? (function(o, m2, k2, k22) {
|
|
106129
|
-
if (k22 === void 0) k22 = k2;
|
|
106130
|
-
var desc = Object.getOwnPropertyDescriptor(m2, k2);
|
|
106131
|
-
if (!desc || ("get" in desc ? !m2.__esModule : desc.writable || desc.configurable)) {
|
|
106132
|
-
desc = { enumerable: true, get: function() {
|
|
106133
|
-
return m2[k2];
|
|
106134
|
-
} };
|
|
106135
|
-
}
|
|
106136
|
-
Object.defineProperty(o, k22, desc);
|
|
106137
|
-
}) : (function(o, m2, k2, k22) {
|
|
106138
|
-
if (k22 === void 0) k22 = k2;
|
|
106139
|
-
o[k22] = m2[k2];
|
|
106140
|
-
}));
|
|
106141
|
-
var __exportStar2 = exports && exports.__exportStar || function(m2, exports2) {
|
|
106142
|
-
for (var p2 in m2) if (p2 !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p2)) __createBinding2(exports2, m2, p2);
|
|
106143
|
-
};
|
|
106144
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
106145
|
-
__exportStar2(require_backend(), exports);
|
|
106146
|
-
__exportStar2(require_env(), exports);
|
|
106147
|
-
__exportStar2(require_inference_session(), exports);
|
|
106148
|
-
__exportStar2(require_tensor(), exports);
|
|
106149
|
-
__exportStar2(require_tensor_conversion(), exports);
|
|
106150
|
-
__exportStar2(require_tensor_factory(), exports);
|
|
106151
|
-
__exportStar2(require_trace(), exports);
|
|
106152
|
-
__exportStar2(require_onnx_model(), exports);
|
|
106153
|
-
__exportStar2(require_onnx_value(), exports);
|
|
106154
|
-
}
|
|
106155
|
-
});
|
|
106156
|
-
|
|
106157
|
-
// ../../node_modules/.bun/onnxruntime-node@1.26.0/node_modules/onnxruntime-node/bin/napi-v6/darwin/arm64/onnxruntime_binding.node
|
|
106158
|
-
var require_onnxruntime_binding = __commonJS({
|
|
106159
|
-
"../../node_modules/.bun/onnxruntime-node@1.26.0/node_modules/onnxruntime-node/bin/napi-v6/darwin/arm64/onnxruntime_binding.node"(exports, module) {
|
|
106160
|
-
module.exports = "./onnxruntime_binding-5J67DTMJ.node";
|
|
106161
|
-
}
|
|
106162
|
-
});
|
|
106163
|
-
|
|
106164
|
-
// ../../node_modules/.bun/onnxruntime-node@1.26.0/node_modules/onnxruntime-node/bin/napi-v6/linux/arm64/onnxruntime_binding.node
|
|
106165
|
-
var require_onnxruntime_binding2 = __commonJS({
|
|
106166
|
-
"../../node_modules/.bun/onnxruntime-node@1.26.0/node_modules/onnxruntime-node/bin/napi-v6/linux/arm64/onnxruntime_binding.node"(exports, module) {
|
|
106167
|
-
module.exports = "./onnxruntime_binding-2BPLI7ZQ.node";
|
|
106168
|
-
}
|
|
106169
|
-
});
|
|
106170
|
-
|
|
106171
|
-
// ../../node_modules/.bun/onnxruntime-node@1.26.0/node_modules/onnxruntime-node/bin/napi-v6/linux/x64/onnxruntime_binding.node
|
|
106172
|
-
var require_onnxruntime_binding3 = __commonJS({
|
|
106173
|
-
"../../node_modules/.bun/onnxruntime-node@1.26.0/node_modules/onnxruntime-node/bin/napi-v6/linux/x64/onnxruntime_binding.node"(exports, module) {
|
|
106174
|
-
module.exports = "./onnxruntime_binding-7ZZLEQ2F.node";
|
|
106175
|
-
}
|
|
106176
|
-
});
|
|
106177
|
-
|
|
106178
|
-
// ../../node_modules/.bun/onnxruntime-node@1.26.0/node_modules/onnxruntime-node/bin/napi-v6/win32/arm64/onnxruntime_binding.node
|
|
106179
|
-
var require_onnxruntime_binding4 = __commonJS({
|
|
106180
|
-
"../../node_modules/.bun/onnxruntime-node@1.26.0/node_modules/onnxruntime-node/bin/napi-v6/win32/arm64/onnxruntime_binding.node"(exports, module) {
|
|
106181
|
-
module.exports = "./onnxruntime_binding-R73P2IQW.node";
|
|
106182
|
-
}
|
|
106183
|
-
});
|
|
106184
|
-
|
|
106185
|
-
// ../../node_modules/.bun/onnxruntime-node@1.26.0/node_modules/onnxruntime-node/bin/napi-v6/win32/x64/onnxruntime_binding.node
|
|
106186
|
-
var require_onnxruntime_binding5 = __commonJS({
|
|
106187
|
-
"../../node_modules/.bun/onnxruntime-node@1.26.0/node_modules/onnxruntime-node/bin/napi-v6/win32/x64/onnxruntime_binding.node"(exports, module) {
|
|
106188
|
-
module.exports = "./onnxruntime_binding-KDCXAPN5.node";
|
|
106189
|
-
}
|
|
106190
|
-
});
|
|
106191
|
-
|
|
106192
|
-
// require("../bin/napi-v6/**/*/**/*/onnxruntime_binding.node") in ../../node_modules/.bun/onnxruntime-node@1.26.0/node_modules/onnxruntime-node/dist/binding.js
|
|
106193
|
-
var globRequire_bin_napi_v6_onnxruntime_binding_node;
|
|
106194
|
-
var init_ = __esm({
|
|
106195
|
-
'require("../bin/napi-v6/**/*/**/*/onnxruntime_binding.node") in ../../node_modules/.bun/onnxruntime-node@1.26.0/node_modules/onnxruntime-node/dist/binding.js'() {
|
|
106196
|
-
globRequire_bin_napi_v6_onnxruntime_binding_node = __glob({
|
|
106197
|
-
"../bin/napi-v6/darwin/arm64/onnxruntime_binding.node": () => require_onnxruntime_binding(),
|
|
106198
|
-
"../bin/napi-v6/linux/arm64/onnxruntime_binding.node": () => require_onnxruntime_binding2(),
|
|
106199
|
-
"../bin/napi-v6/linux/x64/onnxruntime_binding.node": () => require_onnxruntime_binding3(),
|
|
106200
|
-
"../bin/napi-v6/win32/arm64/onnxruntime_binding.node": () => require_onnxruntime_binding4(),
|
|
106201
|
-
"../bin/napi-v6/win32/x64/onnxruntime_binding.node": () => require_onnxruntime_binding5()
|
|
106202
|
-
});
|
|
106203
|
-
}
|
|
106204
|
-
});
|
|
106205
|
-
|
|
106206
|
-
// ../../node_modules/.bun/onnxruntime-node@1.26.0/node_modules/onnxruntime-node/dist/binding.js
|
|
106207
|
-
var require_binding = __commonJS({
|
|
106208
|
-
"../../node_modules/.bun/onnxruntime-node@1.26.0/node_modules/onnxruntime-node/dist/binding.js"(exports) {
|
|
106209
|
-
"use strict";
|
|
106210
|
-
init_();
|
|
106211
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
106212
|
-
exports.initOrt = exports.binding = void 0;
|
|
106213
|
-
var worker_threads_1 = __require("worker_threads");
|
|
106214
|
-
var onnxruntime_common_1 = require_cjs();
|
|
106215
|
-
exports.binding = globRequire_bin_napi_v6_onnxruntime_binding_node(`../bin/napi-v6/${process.platform}/${process.arch}/onnxruntime_binding.node`);
|
|
106216
|
-
var ortInitialized = false;
|
|
106217
|
-
var initOrt = () => {
|
|
106218
|
-
if (!ortInitialized) {
|
|
106219
|
-
ortInitialized = true;
|
|
106220
|
-
let logLevel = 2;
|
|
106221
|
-
if (onnxruntime_common_1.env.logLevel) {
|
|
106222
|
-
switch (onnxruntime_common_1.env.logLevel) {
|
|
106223
|
-
case "verbose":
|
|
106224
|
-
logLevel = 0;
|
|
106225
|
-
break;
|
|
106226
|
-
case "info":
|
|
106227
|
-
logLevel = 1;
|
|
106228
|
-
break;
|
|
106229
|
-
case "warning":
|
|
106230
|
-
logLevel = 2;
|
|
106231
|
-
break;
|
|
106232
|
-
case "error":
|
|
106233
|
-
logLevel = 3;
|
|
106234
|
-
break;
|
|
106235
|
-
case "fatal":
|
|
106236
|
-
logLevel = 4;
|
|
106237
|
-
break;
|
|
106238
|
-
default:
|
|
106239
|
-
throw new Error(`Unsupported log level: ${onnxruntime_common_1.env.logLevel}`);
|
|
106240
|
-
}
|
|
106241
|
-
}
|
|
106242
|
-
exports.binding.initOrtOnce(logLevel, onnxruntime_common_1.Tensor, worker_threads_1.isMainThread);
|
|
106243
|
-
}
|
|
106244
|
-
};
|
|
106245
|
-
exports.initOrt = initOrt;
|
|
106246
|
-
}
|
|
106247
|
-
});
|
|
106248
|
-
|
|
106249
|
-
// ../../node_modules/.bun/onnxruntime-node@1.26.0/node_modules/onnxruntime-node/dist/backend.js
|
|
106250
|
-
var require_backend2 = __commonJS({
|
|
106251
|
-
"../../node_modules/.bun/onnxruntime-node@1.26.0/node_modules/onnxruntime-node/dist/backend.js"(exports) {
|
|
106252
|
-
"use strict";
|
|
106253
|
-
var __classPrivateFieldSet2 = exports && exports.__classPrivateFieldSet || function(receiver, state, value, kind, f3) {
|
|
106254
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
106255
|
-
if (kind === "a" && !f3) throw new TypeError("Private accessor was defined without a setter");
|
|
106256
|
-
if (typeof state === "function" ? receiver !== state || !f3 : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
106257
|
-
return kind === "a" ? f3.call(receiver, value) : f3 ? f3.value = value : state.set(receiver, value), value;
|
|
106258
|
-
};
|
|
106259
|
-
var __classPrivateFieldGet2 = exports && exports.__classPrivateFieldGet || function(receiver, state, kind, f3) {
|
|
106260
|
-
if (kind === "a" && !f3) throw new TypeError("Private accessor was defined without a getter");
|
|
106261
|
-
if (typeof state === "function" ? receiver !== state || !f3 : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
106262
|
-
return kind === "m" ? f3 : kind === "a" ? f3.call(receiver) : f3 ? f3.value : state.get(receiver);
|
|
106263
|
-
};
|
|
106264
|
-
var _OnnxruntimeSessionHandler_inferenceSession;
|
|
106265
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
106266
|
-
exports.listSupportedBackends = exports.onnxruntimeBackend = void 0;
|
|
106267
|
-
var binding_1 = require_binding();
|
|
106268
|
-
var dataTypeStrings = [
|
|
106269
|
-
void 0,
|
|
106270
|
-
"float32",
|
|
106271
|
-
"uint8",
|
|
106272
|
-
"int8",
|
|
106273
|
-
"uint16",
|
|
106274
|
-
"int16",
|
|
106275
|
-
"int32",
|
|
106276
|
-
"int64",
|
|
106277
|
-
"string",
|
|
106278
|
-
"bool",
|
|
106279
|
-
"float16",
|
|
106280
|
-
"float64",
|
|
106281
|
-
"uint32",
|
|
106282
|
-
"uint64",
|
|
106283
|
-
void 0,
|
|
106284
|
-
void 0,
|
|
106285
|
-
void 0,
|
|
106286
|
-
void 0,
|
|
106287
|
-
void 0,
|
|
106288
|
-
void 0,
|
|
106289
|
-
void 0,
|
|
106290
|
-
"uint4",
|
|
106291
|
-
"int4"
|
|
106292
|
-
];
|
|
106293
|
-
var OnnxruntimeSessionHandler = class {
|
|
106294
|
-
constructor(pathOrBuffer, options) {
|
|
106295
|
-
_OnnxruntimeSessionHandler_inferenceSession.set(this, void 0);
|
|
106296
|
-
(0, binding_1.initOrt)();
|
|
106297
|
-
__classPrivateFieldSet2(this, _OnnxruntimeSessionHandler_inferenceSession, new binding_1.binding.InferenceSession(), "f");
|
|
106298
|
-
if (typeof pathOrBuffer === "string") {
|
|
106299
|
-
__classPrivateFieldGet2(this, _OnnxruntimeSessionHandler_inferenceSession, "f").loadModel(pathOrBuffer, options);
|
|
106300
|
-
} else {
|
|
106301
|
-
__classPrivateFieldGet2(this, _OnnxruntimeSessionHandler_inferenceSession, "f").loadModel(pathOrBuffer.buffer, pathOrBuffer.byteOffset, pathOrBuffer.byteLength, options);
|
|
106302
|
-
}
|
|
106303
|
-
this.inputNames = [];
|
|
106304
|
-
this.outputNames = [];
|
|
106305
|
-
this.inputMetadata = [];
|
|
106306
|
-
this.outputMetadata = [];
|
|
106307
|
-
const fillNamesAndMetadata = (rawMetadata) => {
|
|
106308
|
-
const names = [];
|
|
106309
|
-
const metadata = [];
|
|
106310
|
-
for (const m2 of rawMetadata) {
|
|
106311
|
-
names.push(m2.name);
|
|
106312
|
-
if (!m2.isTensor) {
|
|
106313
|
-
metadata.push({ name: m2.name, isTensor: false });
|
|
106314
|
-
} else {
|
|
106315
|
-
const type = dataTypeStrings[m2.type];
|
|
106316
|
-
if (type === void 0) {
|
|
106317
|
-
throw new Error(`Unsupported data type: ${m2.type}`);
|
|
106318
|
-
}
|
|
106319
|
-
const shape = [];
|
|
106320
|
-
for (let i2 = 0; i2 < m2.shape.length; ++i2) {
|
|
106321
|
-
const dim = m2.shape[i2];
|
|
106322
|
-
if (dim === -1) {
|
|
106323
|
-
shape.push(m2.symbolicDimensions[i2]);
|
|
106324
|
-
} else if (dim >= 0) {
|
|
106325
|
-
shape.push(dim);
|
|
106326
|
-
} else {
|
|
106327
|
-
throw new Error(`Invalid dimension: ${dim}`);
|
|
106328
|
-
}
|
|
106329
|
-
}
|
|
106330
|
-
metadata.push({
|
|
106331
|
-
name: m2.name,
|
|
106332
|
-
isTensor: m2.isTensor,
|
|
106333
|
-
type,
|
|
106334
|
-
shape
|
|
106335
|
-
});
|
|
106336
|
-
}
|
|
106337
|
-
}
|
|
106338
|
-
return [names, metadata];
|
|
106339
|
-
};
|
|
106340
|
-
[this.inputNames, this.inputMetadata] = fillNamesAndMetadata(__classPrivateFieldGet2(this, _OnnxruntimeSessionHandler_inferenceSession, "f").inputMetadata);
|
|
106341
|
-
[this.outputNames, this.outputMetadata] = fillNamesAndMetadata(__classPrivateFieldGet2(this, _OnnxruntimeSessionHandler_inferenceSession, "f").outputMetadata);
|
|
106342
|
-
}
|
|
106343
|
-
async dispose() {
|
|
106344
|
-
__classPrivateFieldGet2(this, _OnnxruntimeSessionHandler_inferenceSession, "f").dispose();
|
|
106345
|
-
}
|
|
106346
|
-
startProfiling() {
|
|
106347
|
-
}
|
|
106348
|
-
endProfiling() {
|
|
106349
|
-
__classPrivateFieldGet2(this, _OnnxruntimeSessionHandler_inferenceSession, "f").endProfiling();
|
|
106350
|
-
}
|
|
106351
|
-
async run(feeds, fetches, options) {
|
|
106352
|
-
return new Promise((resolve56, reject) => {
|
|
106353
|
-
setImmediate(() => {
|
|
106354
|
-
try {
|
|
106355
|
-
resolve56(__classPrivateFieldGet2(this, _OnnxruntimeSessionHandler_inferenceSession, "f").run(feeds, fetches, options));
|
|
106356
|
-
} catch (e3) {
|
|
106357
|
-
reject(e3);
|
|
106358
|
-
}
|
|
106359
|
-
});
|
|
106360
|
-
});
|
|
106361
|
-
}
|
|
106362
|
-
};
|
|
106363
|
-
_OnnxruntimeSessionHandler_inferenceSession = /* @__PURE__ */ new WeakMap();
|
|
106364
|
-
var OnnxruntimeBackend = class {
|
|
106365
|
-
async init() {
|
|
106366
|
-
return Promise.resolve();
|
|
106367
|
-
}
|
|
106368
|
-
async createInferenceSessionHandler(pathOrBuffer, options) {
|
|
106369
|
-
return new Promise((resolve56, reject) => {
|
|
106370
|
-
setImmediate(() => {
|
|
106371
|
-
try {
|
|
106372
|
-
resolve56(new OnnxruntimeSessionHandler(pathOrBuffer, options || {}));
|
|
106373
|
-
} catch (e3) {
|
|
106374
|
-
reject(e3);
|
|
106375
|
-
}
|
|
106376
|
-
});
|
|
106377
|
-
});
|
|
106378
|
-
}
|
|
106379
|
-
};
|
|
106380
|
-
exports.onnxruntimeBackend = new OnnxruntimeBackend();
|
|
106381
|
-
exports.listSupportedBackends = binding_1.binding.listSupportedBackends;
|
|
106382
|
-
}
|
|
106383
|
-
});
|
|
106384
|
-
|
|
106385
|
-
// ../../node_modules/.bun/onnxruntime-node@1.26.0/node_modules/onnxruntime-node/dist/version.js
|
|
106386
|
-
var require_version2 = __commonJS({
|
|
106387
|
-
"../../node_modules/.bun/onnxruntime-node@1.26.0/node_modules/onnxruntime-node/dist/version.js"(exports) {
|
|
106388
|
-
"use strict";
|
|
106389
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
106390
|
-
exports.version = void 0;
|
|
106391
|
-
exports.version = "1.26.0";
|
|
106392
|
-
}
|
|
106393
|
-
});
|
|
106394
|
-
|
|
106395
|
-
// ../../node_modules/.bun/onnxruntime-node@1.26.0/node_modules/onnxruntime-node/dist/index.js
|
|
106396
|
-
var require_dist2 = __commonJS({
|
|
106397
|
-
"../../node_modules/.bun/onnxruntime-node@1.26.0/node_modules/onnxruntime-node/dist/index.js"(exports) {
|
|
106398
|
-
"use strict";
|
|
106399
|
-
var __createBinding2 = exports && exports.__createBinding || (Object.create ? (function(o, m2, k2, k22) {
|
|
106400
|
-
if (k22 === void 0) k22 = k2;
|
|
106401
|
-
var desc = Object.getOwnPropertyDescriptor(m2, k2);
|
|
106402
|
-
if (!desc || ("get" in desc ? !m2.__esModule : desc.writable || desc.configurable)) {
|
|
106403
|
-
desc = { enumerable: true, get: function() {
|
|
106404
|
-
return m2[k2];
|
|
106405
|
-
} };
|
|
106406
|
-
}
|
|
106407
|
-
Object.defineProperty(o, k22, desc);
|
|
106408
|
-
}) : (function(o, m2, k2, k22) {
|
|
106409
|
-
if (k22 === void 0) k22 = k2;
|
|
106410
|
-
o[k22] = m2[k2];
|
|
106411
|
-
}));
|
|
106412
|
-
var __exportStar2 = exports && exports.__exportStar || function(m2, exports2) {
|
|
106413
|
-
for (var p2 in m2) if (p2 !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p2)) __createBinding2(exports2, m2, p2);
|
|
106414
|
-
};
|
|
106415
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
106416
|
-
exports.listSupportedBackends = void 0;
|
|
106417
|
-
__exportStar2(require_cjs(), exports);
|
|
106418
|
-
var backend_1 = require_backend2();
|
|
106419
|
-
Object.defineProperty(exports, "listSupportedBackends", { enumerable: true, get: function() {
|
|
106420
|
-
return backend_1.listSupportedBackends;
|
|
106421
|
-
} });
|
|
106422
|
-
var onnxruntime_common_1 = require_cjs();
|
|
106423
|
-
var version_1 = require_version2();
|
|
106424
|
-
var backend_2 = require_backend2();
|
|
106425
|
-
var backends = (0, backend_2.listSupportedBackends)();
|
|
106426
|
-
for (const backend of backends) {
|
|
106427
|
-
(0, onnxruntime_common_1.registerBackend)(backend.name, backend_2.onnxruntimeBackend, 100);
|
|
106428
|
-
}
|
|
106429
|
-
Object.defineProperty(onnxruntime_common_1.env.versions, "node", { value: version_1.version, enumerable: true });
|
|
106430
|
-
}
|
|
106431
|
-
});
|
|
106432
|
-
|
|
106433
104860
|
// src/background-removal/inference.ts
|
|
106434
104861
|
async function loadNative(name, load) {
|
|
106435
104862
|
try {
|
|
@@ -106443,7 +104870,7 @@ async function loadNative(name, load) {
|
|
|
106443
104870
|
async function createSession(options = {}) {
|
|
106444
104871
|
const ort = await loadNative(
|
|
106445
104872
|
"onnxruntime-node",
|
|
106446
|
-
() =>
|
|
104873
|
+
() => import("onnxruntime-node")
|
|
106447
104874
|
);
|
|
106448
104875
|
const sharp2 = (await loadNative("sharp", () => import("sharp"))).default;
|
|
106449
104876
|
const choice = selectProviders(options.device ?? "auto");
|
|
@@ -106951,6 +105378,7 @@ var init_remove_background = __esm({
|
|
|
106951
105378
|
init_colors();
|
|
106952
105379
|
init_manager3();
|
|
106953
105380
|
init_pipeline();
|
|
105381
|
+
init_events();
|
|
106954
105382
|
examples16 = [
|
|
106955
105383
|
[
|
|
106956
105384
|
"Remove background from a video, output transparent VP9 WebM (default)",
|
|
@@ -107105,6 +105533,7 @@ var init_remove_background = __esm({
|
|
|
107105
105533
|
}
|
|
107106
105534
|
} catch (err) {
|
|
107107
105535
|
const message = err instanceof Error ? err.message : String(err);
|
|
105536
|
+
trackCommandFailure("remove-background", err);
|
|
107108
105537
|
if (args.json) {
|
|
107109
105538
|
console.log(JSON.stringify({ ok: false, error: message }));
|
|
107110
105539
|
} else {
|
|
@@ -109791,7 +108220,7 @@ var require_helpers = __commonJS({
|
|
|
109791
108220
|
});
|
|
109792
108221
|
|
|
109793
108222
|
// ../../node_modules/.bun/agent-base@7.1.4/node_modules/agent-base/dist/index.js
|
|
109794
|
-
var
|
|
108223
|
+
var require_dist2 = __commonJS({
|
|
109795
108224
|
"../../node_modules/.bun/agent-base@7.1.4/node_modules/agent-base/dist/index.js"(exports) {
|
|
109796
108225
|
"use strict";
|
|
109797
108226
|
var __createBinding2 = exports && exports.__createBinding || (Object.create ? (function(o, m2, k2, k22) {
|
|
@@ -110043,7 +108472,7 @@ var require_parse_proxy_response = __commonJS({
|
|
|
110043
108472
|
});
|
|
110044
108473
|
|
|
110045
108474
|
// ../../node_modules/.bun/https-proxy-agent@7.0.6/node_modules/https-proxy-agent/dist/index.js
|
|
110046
|
-
var
|
|
108475
|
+
var require_dist3 = __commonJS({
|
|
110047
108476
|
"../../node_modules/.bun/https-proxy-agent@7.0.6/node_modules/https-proxy-agent/dist/index.js"(exports) {
|
|
110048
108477
|
"use strict";
|
|
110049
108478
|
var __createBinding2 = exports && exports.__createBinding || (Object.create ? (function(o, m2, k2, k22) {
|
|
@@ -110082,7 +108511,7 @@ var require_dist4 = __commonJS({
|
|
|
110082
108511
|
var tls = __importStar2(__require("tls"));
|
|
110083
108512
|
var assert_1 = __importDefault2(__require("assert"));
|
|
110084
108513
|
var debug_1 = __importDefault2(__require("debug"));
|
|
110085
|
-
var agent_base_1 =
|
|
108514
|
+
var agent_base_1 = require_dist2();
|
|
110086
108515
|
var url_1 = __require("url");
|
|
110087
108516
|
var parse_proxy_response_1 = require_parse_proxy_response();
|
|
110088
108517
|
var debug = (0, debug_1.default)("https-proxy-agent");
|
|
@@ -117134,7 +115563,7 @@ Content-Type: ${partContentType}\r
|
|
|
117134
115563
|
* @returns A proxy agent
|
|
117135
115564
|
*/
|
|
117136
115565
|
static async #getProxyAgent() {
|
|
117137
|
-
this.#proxyAgent ||= (await Promise.resolve().then(() => __toESM(
|
|
115566
|
+
this.#proxyAgent ||= (await Promise.resolve().then(() => __toESM(require_dist3()))).HttpsProxyAgent;
|
|
117138
115567
|
return this.#proxyAgent;
|
|
117139
115568
|
}
|
|
117140
115569
|
static async #getFetch() {
|