web-sdk-pp-detection 0.1.0 → 0.2.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/README.md +30 -20
- package/dist/browser-global.js +335 -93
- package/dist/browser-global.js.map +1 -1
- package/dist/index.d.ts +29 -3
- package/dist/index.js +335 -93
- package/dist/index.js.map +1 -1
- package/dist/inference.worker.js +14 -5
- package/dist/inference.worker.js.map +1 -1
- package/package.json +1 -1
package/dist/inference.worker.js
CHANGED
|
@@ -13649,14 +13649,15 @@ function now() {
|
|
|
13649
13649
|
function mapError(error, phase) {
|
|
13650
13650
|
if (error instanceof PPDetectionError) return error;
|
|
13651
13651
|
const message = error instanceof Error ? error.message : String(error);
|
|
13652
|
-
|
|
13653
|
-
|
|
13652
|
+
const details = { phase, causeMessage: message };
|
|
13653
|
+
if (error instanceof Error && error.name === "AbortError")
|
|
13654
|
+
return new PPDetectionError("ABORTED", "\u63A8\u7406\u5DF2\u53D6\u6D88", details, { cause: error });
|
|
13654
13655
|
if (/memory|out.of.memory|allocation/i.test(message))
|
|
13655
|
-
return new PPDetectionError("OUT_OF_MEMORY", "\u8FD0\u884C\u65F6\u5185\u5B58\u4E0D\u8DB3",
|
|
13656
|
+
return new PPDetectionError("OUT_OF_MEMORY", "\u8FD0\u884C\u65F6\u5185\u5B58\u4E0D\u8DB3", details, { cause: error });
|
|
13656
13657
|
return new PPDetectionError(
|
|
13657
13658
|
phase === "create" ? "SESSION_CREATE_FAILED" : "INFERENCE_FAILED",
|
|
13658
13659
|
phase === "create" ? "\u521B\u5EFA ONNX Runtime \u4F1A\u8BDD\u5931\u8D25" : "ONNX Runtime \u63A8\u7406\u5931\u8D25",
|
|
13659
|
-
|
|
13660
|
+
details,
|
|
13660
13661
|
{ cause: error }
|
|
13661
13662
|
);
|
|
13662
13663
|
}
|
|
@@ -13694,6 +13695,7 @@ async function createOrtSession(modelBytes, plan, options = {}) {
|
|
|
13694
13695
|
return {
|
|
13695
13696
|
plan,
|
|
13696
13697
|
sessionMs,
|
|
13698
|
+
runtimeVersion: ort.env.versions?.web ?? null,
|
|
13697
13699
|
async run(feeds, runOptions = {}) {
|
|
13698
13700
|
if (disposed) throw new PPDetectionError("DISPOSED", "\u4F1A\u8BDD\u5DF2\u91CA\u653E", { phase: "run" });
|
|
13699
13701
|
if (runOptions.signal?.aborted)
|
|
@@ -13818,7 +13820,14 @@ workerScope.onmessage = async (event) => {
|
|
|
13818
13820
|
const previousSession = session;
|
|
13819
13821
|
session = nextSession;
|
|
13820
13822
|
await previousSession?.dispose();
|
|
13821
|
-
send({
|
|
13823
|
+
send({
|
|
13824
|
+
id: request.id,
|
|
13825
|
+
type: "result",
|
|
13826
|
+
result: {
|
|
13827
|
+
loaded: true,
|
|
13828
|
+
runtimeVersion: nextSession.runtimeVersion ?? null
|
|
13829
|
+
}
|
|
13830
|
+
});
|
|
13822
13831
|
return;
|
|
13823
13832
|
}
|
|
13824
13833
|
if (request.type === "run") {
|