@camstack/addon-vision 0.1.1 → 0.1.3

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.
Files changed (111) hide show
  1. package/dist/addons/animal-classifier/index.js +999 -823
  2. package/dist/addons/animal-classifier/index.js.map +1 -1
  3. package/dist/addons/animal-classifier/index.mjs +242 -7
  4. package/dist/addons/animal-classifier/index.mjs.map +1 -1
  5. package/dist/addons/audio-classification/index.js +501 -379
  6. package/dist/addons/audio-classification/index.js.map +1 -1
  7. package/dist/addons/audio-classification/index.mjs +224 -4
  8. package/dist/addons/audio-classification/index.mjs.map +1 -1
  9. package/dist/addons/bird-global-classifier/index.js +1002 -826
  10. package/dist/addons/bird-global-classifier/index.js.map +1 -1
  11. package/dist/addons/bird-global-classifier/index.mjs +248 -7
  12. package/dist/addons/bird-global-classifier/index.mjs.map +1 -1
  13. package/dist/addons/bird-nabirds-classifier/index.js +1002 -826
  14. package/dist/addons/bird-nabirds-classifier/index.js.map +1 -1
  15. package/dist/addons/bird-nabirds-classifier/index.mjs +289 -7
  16. package/dist/addons/bird-nabirds-classifier/index.mjs.map +1 -1
  17. package/dist/addons/face-detection/index.js +1196 -935
  18. package/dist/addons/face-detection/index.js.map +1 -1
  19. package/dist/addons/face-detection/index.mjs +227 -7
  20. package/dist/addons/face-detection/index.mjs.map +1 -1
  21. package/dist/addons/face-recognition/index.js +1003 -808
  22. package/dist/addons/face-recognition/index.js.map +1 -1
  23. package/dist/addons/face-recognition/index.mjs +197 -6
  24. package/dist/addons/face-recognition/index.mjs.map +1 -1
  25. package/dist/addons/motion-detection/index.js +214 -111
  26. package/dist/addons/motion-detection/index.js.map +1 -1
  27. package/dist/addons/motion-detection/index.mjs +12 -9
  28. package/dist/addons/motion-detection/index.mjs.map +1 -1
  29. package/dist/addons/object-detection/index.js +1287 -1083
  30. package/dist/addons/object-detection/index.js.map +1 -1
  31. package/dist/addons/object-detection/index.mjs +373 -7
  32. package/dist/addons/object-detection/index.mjs.map +1 -1
  33. package/dist/addons/plate-detection/index.js +1075 -869
  34. package/dist/addons/plate-detection/index.js.map +1 -1
  35. package/dist/addons/plate-detection/index.mjs +230 -7
  36. package/dist/addons/plate-detection/index.mjs.map +1 -1
  37. package/dist/addons/plate-recognition/index.js +684 -506
  38. package/dist/addons/plate-recognition/index.js.map +1 -1
  39. package/dist/addons/plate-recognition/index.mjs +244 -5
  40. package/dist/addons/plate-recognition/index.mjs.map +1 -1
  41. package/dist/addons/segmentation-refiner/index.js +967 -791
  42. package/dist/addons/segmentation-refiner/index.js.map +1 -1
  43. package/dist/addons/segmentation-refiner/index.mjs +21 -17
  44. package/dist/addons/segmentation-refiner/index.mjs.map +1 -1
  45. package/dist/addons/vehicle-classifier/index.js +581 -411
  46. package/dist/addons/vehicle-classifier/index.js.map +1 -1
  47. package/dist/addons/vehicle-classifier/index.mjs +20 -16
  48. package/dist/addons/vehicle-classifier/index.mjs.map +1 -1
  49. package/dist/chunk-2YMA6QOV.mjs +193 -0
  50. package/dist/chunk-2YMA6QOV.mjs.map +1 -0
  51. package/dist/chunk-3IIFBJCD.mjs +45 -0
  52. package/dist/chunk-BS4DKYGN.mjs +48 -0
  53. package/dist/{chunk-7DYHXUPZ.mjs.map → chunk-BS4DKYGN.mjs.map} +1 -1
  54. package/dist/chunk-DE7I3VHO.mjs +106 -0
  55. package/dist/{chunk-KUO2BVFY.mjs.map → chunk-DE7I3VHO.mjs.map} +1 -1
  56. package/dist/chunk-F6D2OZ36.mjs +89 -0
  57. package/dist/chunk-F6D2OZ36.mjs.map +1 -0
  58. package/dist/chunk-GAOIFQDX.mjs +59 -0
  59. package/dist/chunk-GAOIFQDX.mjs.map +1 -0
  60. package/dist/chunk-HUIX2XVR.mjs +159 -0
  61. package/dist/chunk-HUIX2XVR.mjs.map +1 -0
  62. package/dist/chunk-K36R6HWY.mjs +51 -0
  63. package/dist/{chunk-XZ6ZMXXU.mjs.map → chunk-K36R6HWY.mjs.map} +1 -1
  64. package/dist/chunk-MBTAI3WE.mjs +78 -0
  65. package/dist/chunk-MBTAI3WE.mjs.map +1 -0
  66. package/dist/chunk-MGT6RUVX.mjs +423 -0
  67. package/dist/{chunk-BP7H4NFS.mjs.map → chunk-MGT6RUVX.mjs.map} +1 -1
  68. package/dist/chunk-PIFS7AIT.mjs +446 -0
  69. package/dist/chunk-PIFS7AIT.mjs.map +1 -0
  70. package/dist/chunk-WG66JYYW.mjs +116 -0
  71. package/dist/{chunk-22BHCDT5.mjs.map → chunk-WG66JYYW.mjs.map} +1 -1
  72. package/dist/chunk-XD7WGXHZ.mjs +82 -0
  73. package/dist/{chunk-DUN6XU3N.mjs.map → chunk-XD7WGXHZ.mjs.map} +1 -1
  74. package/dist/chunk-YYDM6V2F.mjs +113 -0
  75. package/dist/{chunk-BR2FPGOX.mjs.map → chunk-YYDM6V2F.mjs.map} +1 -1
  76. package/dist/chunk-ZK7P3TZN.mjs +286 -0
  77. package/dist/chunk-ZK7P3TZN.mjs.map +1 -0
  78. package/dist/index.js +4443 -3925
  79. package/dist/index.js.map +1 -1
  80. package/dist/index.mjs +2698 -250
  81. package/dist/index.mjs.map +1 -1
  82. package/package.json +2 -3
  83. package/dist/chunk-22BHCDT5.mjs +0 -101
  84. package/dist/chunk-6DJZZR64.mjs +0 -336
  85. package/dist/chunk-6DJZZR64.mjs.map +0 -1
  86. package/dist/chunk-7DYHXUPZ.mjs +0 -36
  87. package/dist/chunk-BJTO5JO5.mjs +0 -11
  88. package/dist/chunk-BP7H4NFS.mjs +0 -412
  89. package/dist/chunk-BR2FPGOX.mjs +0 -98
  90. package/dist/chunk-DNQNGDR4.mjs +0 -256
  91. package/dist/chunk-DNQNGDR4.mjs.map +0 -1
  92. package/dist/chunk-DUN6XU3N.mjs +0 -72
  93. package/dist/chunk-EPNWLSCG.mjs +0 -387
  94. package/dist/chunk-EPNWLSCG.mjs.map +0 -1
  95. package/dist/chunk-G32RCIUI.mjs +0 -645
  96. package/dist/chunk-G32RCIUI.mjs.map +0 -1
  97. package/dist/chunk-GR65KM6X.mjs +0 -289
  98. package/dist/chunk-GR65KM6X.mjs.map +0 -1
  99. package/dist/chunk-H7LMBTS5.mjs +0 -276
  100. package/dist/chunk-H7LMBTS5.mjs.map +0 -1
  101. package/dist/chunk-IK4XIQPC.mjs +0 -242
  102. package/dist/chunk-IK4XIQPC.mjs.map +0 -1
  103. package/dist/chunk-J6VNIIYX.mjs +0 -269
  104. package/dist/chunk-J6VNIIYX.mjs.map +0 -1
  105. package/dist/chunk-KUO2BVFY.mjs +0 -90
  106. package/dist/chunk-ML2JX43J.mjs +0 -248
  107. package/dist/chunk-ML2JX43J.mjs.map +0 -1
  108. package/dist/chunk-WUMV524J.mjs +0 -379
  109. package/dist/chunk-WUMV524J.mjs.map +0 -1
  110. package/dist/chunk-XZ6ZMXXU.mjs +0 -39
  111. /package/dist/{chunk-BJTO5JO5.mjs.map → chunk-3IIFBJCD.mjs.map} +0 -0
@@ -1,336 +0,0 @@
1
- // src/shared/node-engine.ts
2
- import * as path from "path";
3
- var BACKEND_TO_PROVIDER = {
4
- cpu: "cpu",
5
- coreml: "coreml",
6
- cuda: "cuda",
7
- tensorrt: "tensorrt",
8
- dml: "dml"
9
- };
10
- var BACKEND_TO_DEVICE = {
11
- cpu: "cpu",
12
- coreml: "gpu-mps",
13
- cuda: "gpu-cuda",
14
- tensorrt: "tensorrt"
15
- };
16
- var NodeInferenceEngine = class {
17
- constructor(modelPath, backend) {
18
- this.modelPath = modelPath;
19
- this.backend = backend;
20
- this.device = BACKEND_TO_DEVICE[backend] ?? "cpu";
21
- }
22
- runtime = "onnx";
23
- device;
24
- session = null;
25
- async initialize() {
26
- const ort = await import("onnxruntime-node");
27
- const provider = BACKEND_TO_PROVIDER[this.backend] ?? "cpu";
28
- const absModelPath = path.isAbsolute(this.modelPath) ? this.modelPath : path.resolve(process.cwd(), this.modelPath);
29
- const sessionOptions = {
30
- executionProviders: [provider]
31
- };
32
- this.session = await ort.InferenceSession.create(absModelPath, sessionOptions);
33
- }
34
- async run(input, inputShape) {
35
- if (!this.session) {
36
- throw new Error("NodeInferenceEngine: not initialized \u2014 call initialize() first");
37
- }
38
- const ort = await import("onnxruntime-node");
39
- const sess = this.session;
40
- const inputName = sess.inputNames[0];
41
- const tensor = new ort.Tensor("float32", input, [...inputShape]);
42
- const feeds = { [inputName]: tensor };
43
- const results = await sess.run(feeds);
44
- const outputName = sess.outputNames[0];
45
- const outputTensor = results[outputName];
46
- return outputTensor.data;
47
- }
48
- async runMultiOutput(input, inputShape) {
49
- if (!this.session) {
50
- throw new Error("NodeInferenceEngine: not initialized \u2014 call initialize() first");
51
- }
52
- const ort = await import("onnxruntime-node");
53
- const sess = this.session;
54
- const inputName = sess.inputNames[0];
55
- const tensor = new ort.Tensor("float32", input, [...inputShape]);
56
- const feeds = { [inputName]: tensor };
57
- const results = await sess.run(feeds);
58
- const out = {};
59
- for (const name of sess.outputNames) {
60
- out[name] = results[name].data;
61
- }
62
- return out;
63
- }
64
- async dispose() {
65
- this.session = null;
66
- }
67
- };
68
-
69
- // src/shared/python-engine.ts
70
- import { spawn } from "child_process";
71
- import { ensurePython } from "@camstack/core";
72
- var PythonInferenceEngine = class {
73
- constructor(pythonPath, scriptPath, runtime, modelPath, extraArgs = []) {
74
- this.pythonPath = pythonPath;
75
- this.scriptPath = scriptPath;
76
- this.modelPath = modelPath;
77
- this.extraArgs = extraArgs;
78
- this.runtime = runtime;
79
- const runtimeDeviceMap = {
80
- onnx: "cpu",
81
- coreml: "gpu-mps",
82
- pytorch: "cpu",
83
- openvino: "cpu",
84
- tflite: "cpu"
85
- };
86
- this.device = runtimeDeviceMap[runtime];
87
- }
88
- runtime;
89
- device;
90
- process = null;
91
- receiveBuffer = Buffer.alloc(0);
92
- pendingResolve = null;
93
- pendingReject = null;
94
- async initialize() {
95
- const args = [this.scriptPath, this.modelPath, ...this.extraArgs];
96
- this.process = spawn(this.pythonPath, args, {
97
- stdio: ["pipe", "pipe", "pipe"]
98
- });
99
- if (!this.process.stdout || !this.process.stdin) {
100
- throw new Error("PythonInferenceEngine: failed to create process pipes");
101
- }
102
- this.process.stderr?.on("data", (chunk) => {
103
- process.stderr.write(`[python-engine] ${chunk.toString()}`);
104
- });
105
- this.process.on("error", (err) => {
106
- this.pendingReject?.(err);
107
- this.pendingReject = null;
108
- this.pendingResolve = null;
109
- });
110
- this.process.on("exit", (code) => {
111
- if (code !== 0) {
112
- const err = new Error(`PythonInferenceEngine: process exited with code ${code}`);
113
- this.pendingReject?.(err);
114
- this.pendingReject = null;
115
- this.pendingResolve = null;
116
- }
117
- });
118
- this.process.stdout.on("data", (chunk) => {
119
- this.receiveBuffer = Buffer.concat([this.receiveBuffer, chunk]);
120
- this._tryReceive();
121
- });
122
- await new Promise((resolve2, reject) => {
123
- const timeout = setTimeout(() => resolve2(), 2e3);
124
- this.process?.on("error", (err) => {
125
- clearTimeout(timeout);
126
- reject(err);
127
- });
128
- this.process?.on("exit", (code) => {
129
- clearTimeout(timeout);
130
- if (code !== 0) {
131
- reject(new Error(`PythonInferenceEngine: process exited early with code ${code}`));
132
- }
133
- });
134
- });
135
- }
136
- _tryReceive() {
137
- if (this.receiveBuffer.length < 4) return;
138
- const length = this.receiveBuffer.readUInt32LE(0);
139
- if (this.receiveBuffer.length < 4 + length) return;
140
- const jsonBytes = this.receiveBuffer.subarray(4, 4 + length);
141
- this.receiveBuffer = this.receiveBuffer.subarray(4 + length);
142
- const resolve2 = this.pendingResolve;
143
- const reject = this.pendingReject;
144
- this.pendingResolve = null;
145
- this.pendingReject = null;
146
- if (!resolve2) return;
147
- try {
148
- const parsed = JSON.parse(jsonBytes.toString("utf8"));
149
- resolve2(parsed);
150
- } catch (err) {
151
- reject?.(err instanceof Error ? err : new Error(String(err)));
152
- }
153
- }
154
- /** Send JPEG buffer, receive JSON detection results */
155
- async runJpeg(jpeg) {
156
- if (!this.process?.stdin) {
157
- throw new Error("PythonInferenceEngine: process not initialized");
158
- }
159
- return new Promise((resolve2, reject) => {
160
- this.pendingResolve = resolve2;
161
- this.pendingReject = reject;
162
- const lengthBuf = Buffer.allocUnsafe(4);
163
- lengthBuf.writeUInt32LE(jpeg.length, 0);
164
- this.process.stdin.write(Buffer.concat([lengthBuf, jpeg]));
165
- });
166
- }
167
- /** IInferenceEngine.run — wraps runJpeg for compatibility */
168
- async run(_input, _inputShape) {
169
- throw new Error(
170
- "PythonInferenceEngine: use runJpeg() directly \u2014 this engine operates on JPEG input"
171
- );
172
- }
173
- /** IInferenceEngine.runMultiOutput — not supported by Python engine (operates on JPEG input) */
174
- async runMultiOutput(_input, _inputShape) {
175
- throw new Error(
176
- "PythonInferenceEngine: runMultiOutput() is not supported \u2014 this engine operates on JPEG input"
177
- );
178
- }
179
- async dispose() {
180
- if (this.process) {
181
- this.process.stdin?.end();
182
- this.process.kill("SIGTERM");
183
- this.process = null;
184
- }
185
- }
186
- };
187
-
188
- // src/shared/engine-resolver.ts
189
- import * as fs from "fs";
190
- import * as path2 from "path";
191
- var AUTO_BACKEND_PRIORITY = ["coreml", "cuda", "tensorrt", "cpu"];
192
- var BACKEND_TO_FORMAT = {
193
- cpu: "onnx",
194
- coreml: "onnx",
195
- cuda: "onnx",
196
- tensorrt: "onnx"
197
- };
198
- var RUNTIME_TO_FORMAT = {
199
- onnx: "onnx",
200
- coreml: "coreml",
201
- openvino: "openvino",
202
- tflite: "tflite",
203
- pytorch: "pt"
204
- };
205
- function modelFilePath(modelsDir, modelEntry, format) {
206
- const formatEntry = modelEntry.formats[format];
207
- if (!formatEntry) {
208
- throw new Error(`Model ${modelEntry.id} has no ${format} format`);
209
- }
210
- const urlParts = formatEntry.url.split("/");
211
- const filename = urlParts[urlParts.length - 1] ?? `${modelEntry.id}.${format}`;
212
- return path2.join(modelsDir, filename);
213
- }
214
- function modelExists(filePath) {
215
- try {
216
- return fs.existsSync(filePath);
217
- } catch {
218
- return false;
219
- }
220
- }
221
- async function resolveEngine(options) {
222
- const { runtime, backend, modelEntry, modelsDir, models } = options;
223
- let selectedFormat;
224
- let selectedBackend;
225
- if (runtime === "auto") {
226
- const available = await probeOnnxBackends();
227
- let chosen = null;
228
- for (const b of AUTO_BACKEND_PRIORITY) {
229
- if (!available.includes(b)) continue;
230
- const fmt = BACKEND_TO_FORMAT[b];
231
- if (!fmt) continue;
232
- if (!modelEntry.formats[fmt]) continue;
233
- chosen = { backend: b, format: fmt };
234
- break;
235
- }
236
- if (!chosen) {
237
- throw new Error(
238
- `resolveEngine: no compatible backend found for model ${modelEntry.id}. Available backends: ${available.join(", ")}`
239
- );
240
- }
241
- selectedFormat = chosen.format;
242
- selectedBackend = chosen.backend;
243
- } else {
244
- const fmt = RUNTIME_TO_FORMAT[runtime];
245
- if (!fmt) {
246
- throw new Error(`resolveEngine: unsupported runtime "${runtime}"`);
247
- }
248
- if (!modelEntry.formats[fmt]) {
249
- throw new Error(
250
- `resolveEngine: model ${modelEntry.id} has no ${fmt} format for runtime ${runtime}`
251
- );
252
- }
253
- selectedFormat = fmt;
254
- selectedBackend = runtime === "onnx" ? backend || "cpu" : runtime;
255
- }
256
- let modelPath;
257
- if (models) {
258
- modelPath = await models.ensure(modelEntry.id, selectedFormat);
259
- } else {
260
- modelPath = modelFilePath(modelsDir, modelEntry, selectedFormat);
261
- if (!modelExists(modelPath)) {
262
- throw new Error(
263
- `resolveEngine: model file not found at ${modelPath} and no model service provided`
264
- );
265
- }
266
- }
267
- if (selectedFormat === "onnx") {
268
- const engine = new NodeInferenceEngine(modelPath, selectedBackend);
269
- await engine.initialize();
270
- return { engine, format: selectedFormat, modelPath };
271
- }
272
- const { pythonPath } = options;
273
- const PYTHON_SCRIPT_MAP = {
274
- coreml: "coreml_inference.py",
275
- pytorch: "pytorch_inference.py",
276
- openvino: "openvino_inference.py"
277
- };
278
- const effectiveRuntime = runtime === "auto" ? selectedBackend : runtime;
279
- const scriptName = PYTHON_SCRIPT_MAP[effectiveRuntime];
280
- if (scriptName && pythonPath) {
281
- const candidates = [
282
- path2.join(__dirname, "../../python", scriptName),
283
- path2.join(__dirname, "../python", scriptName),
284
- path2.join(__dirname, "../../../python", scriptName)
285
- ];
286
- const scriptPath = candidates.find((p) => fs.existsSync(p));
287
- if (!scriptPath) {
288
- throw new Error(
289
- `resolveEngine: Python script "${scriptName}" not found. Searched:
290
- ${candidates.join("\n")}`
291
- );
292
- }
293
- const inputSize = Math.max(modelEntry.inputSize.width, modelEntry.inputSize.height);
294
- const engine = new PythonInferenceEngine(pythonPath, scriptPath, effectiveRuntime, modelPath, [
295
- `--input-size=${inputSize}`,
296
- `--confidence=0.25`
297
- ]);
298
- await engine.initialize();
299
- return { engine, format: selectedFormat, modelPath };
300
- }
301
- const fallbackPath = modelFilePath(modelsDir, modelEntry, "onnx");
302
- if (modelEntry.formats["onnx"] && modelExists(fallbackPath)) {
303
- const engine = new NodeInferenceEngine(fallbackPath, "cpu");
304
- await engine.initialize();
305
- return { engine, format: "onnx", modelPath: fallbackPath };
306
- }
307
- throw new Error(
308
- `resolveEngine: format ${selectedFormat} is not yet supported by NodeInferenceEngine, no Python runtime is available, and no ONNX fallback exists`
309
- );
310
- }
311
- async function probeOnnxBackends() {
312
- const available = ["cpu"];
313
- try {
314
- const ort = await import("onnxruntime-node");
315
- const providers = ort.env?.webgl?.disabled !== void 0 ? ort.InferenceSession?.getAvailableProviders?.() ?? [] : [];
316
- for (const p of providers) {
317
- const normalized = p.toLowerCase().replace("executionprovider", "");
318
- if (normalized === "coreml") available.push("coreml");
319
- else if (normalized === "cuda") available.push("cuda");
320
- else if (normalized === "tensorrt") available.push("tensorrt");
321
- }
322
- } catch {
323
- }
324
- if (process.platform === "darwin" && !available.includes("coreml")) {
325
- available.push("coreml");
326
- }
327
- return [...new Set(available)];
328
- }
329
-
330
- export {
331
- NodeInferenceEngine,
332
- PythonInferenceEngine,
333
- resolveEngine,
334
- probeOnnxBackends
335
- };
336
- //# sourceMappingURL=chunk-6DJZZR64.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/shared/node-engine.ts","../src/shared/python-engine.ts","../src/shared/engine-resolver.ts"],"sourcesContent":["import type { IInferenceEngine, DetectionRuntime, DetectionDevice } from '@camstack/types'\nimport * as path from 'node:path'\n\nconst BACKEND_TO_PROVIDER: Readonly<Record<string, string>> = {\n cpu: 'cpu',\n coreml: 'coreml',\n cuda: 'cuda',\n tensorrt: 'tensorrt',\n dml: 'dml',\n} as const\n\nconst BACKEND_TO_DEVICE: Readonly<Record<string, DetectionDevice>> = {\n cpu: 'cpu',\n coreml: 'gpu-mps',\n cuda: 'gpu-cuda',\n tensorrt: 'tensorrt',\n} as const\n\nexport class NodeInferenceEngine implements IInferenceEngine {\n readonly runtime: DetectionRuntime = 'onnx'\n readonly device: DetectionDevice\n private session: unknown = null\n\n constructor(\n private readonly modelPath: string,\n private readonly backend: string,\n ) {\n this.device = (BACKEND_TO_DEVICE[backend] ?? 'cpu') as DetectionDevice\n }\n\n async initialize(): Promise<void> {\n const ort = await import('onnxruntime-node')\n const provider = BACKEND_TO_PROVIDER[this.backend] ?? 'cpu'\n\n // Resolve absolute path\n const absModelPath = path.isAbsolute(this.modelPath)\n ? this.modelPath\n : path.resolve(process.cwd(), this.modelPath)\n\n const sessionOptions: Record<string, unknown> = {\n executionProviders: [provider],\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n this.session = await (ort as any).InferenceSession.create(absModelPath, sessionOptions)\n }\n\n async run(input: Float32Array, inputShape: readonly number[]): Promise<Float32Array> {\n if (!this.session) {\n throw new Error('NodeInferenceEngine: not initialized — call initialize() first')\n }\n\n const ort = await import('onnxruntime-node')\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const sess = this.session as any\n\n // Get the first input name\n const inputName: string = sess.inputNames[0]\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const tensor = new (ort as any).Tensor('float32', input, [...inputShape])\n const feeds: Record<string, unknown> = { [inputName]: tensor }\n\n const results = await sess.run(feeds)\n const outputName: string = sess.outputNames[0]\n const outputTensor = results[outputName]\n\n return outputTensor.data as Float32Array\n }\n\n async runMultiOutput(\n input: Float32Array,\n inputShape: readonly number[],\n ): Promise<Record<string, Float32Array>> {\n if (!this.session) {\n throw new Error('NodeInferenceEngine: not initialized — call initialize() first')\n }\n\n const ort = await import('onnxruntime-node')\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const sess = this.session as any\n\n const inputName: string = sess.inputNames[0]\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const tensor = new (ort as any).Tensor('float32', input, [...inputShape])\n const feeds: Record<string, unknown> = { [inputName]: tensor }\n\n const results = await sess.run(feeds)\n\n const out: Record<string, Float32Array> = {}\n for (const name of sess.outputNames as string[]) {\n out[name] = results[name].data as Float32Array\n }\n return out\n }\n\n async dispose(): Promise<void> {\n // onnxruntime-node sessions don't have explicit close in all versions\n // but we clear the reference\n this.session = null\n }\n}\n","import type { IInferenceEngine, DetectionRuntime, DetectionDevice, IScopedLogger } from '@camstack/types'\nimport { spawn, type ChildProcess } from 'node:child_process'\nimport { ensurePython } from '@camstack/core'\n\nexport class PythonInferenceEngine implements IInferenceEngine {\n readonly runtime: DetectionRuntime\n readonly device: DetectionDevice\n private process: ChildProcess | null = null\n private receiveBuffer: Buffer = Buffer.alloc(0)\n private pendingResolve: ((value: Record<string, unknown>) => void) | null = null\n private pendingReject: ((reason: Error) => void) | null = null\n\n constructor(\n private readonly pythonPath: string,\n private readonly scriptPath: string,\n runtime: DetectionRuntime,\n private readonly modelPath: string,\n private readonly extraArgs: readonly string[] = [],\n ) {\n this.runtime = runtime\n // Determine device from runtime\n const runtimeDeviceMap: Readonly<Record<DetectionRuntime, DetectionDevice>> = {\n onnx: 'cpu',\n coreml: 'gpu-mps',\n pytorch: 'cpu',\n openvino: 'cpu',\n tflite: 'cpu',\n }\n this.device = runtimeDeviceMap[runtime]\n }\n\n async initialize(): Promise<void> {\n const args = [this.scriptPath, this.modelPath, ...this.extraArgs]\n this.process = spawn(this.pythonPath, args, {\n stdio: ['pipe', 'pipe', 'pipe'],\n })\n\n if (!this.process.stdout || !this.process.stdin) {\n throw new Error('PythonInferenceEngine: failed to create process pipes')\n }\n\n this.process.stderr?.on('data', (chunk: Buffer) => {\n // Log stderr from python process for debugging\n process.stderr.write(`[python-engine] ${chunk.toString()}`)\n })\n\n this.process.on('error', (err) => {\n this.pendingReject?.(err)\n this.pendingReject = null\n this.pendingResolve = null\n })\n\n this.process.on('exit', (code) => {\n if (code !== 0) {\n const err = new Error(`PythonInferenceEngine: process exited with code ${code}`)\n this.pendingReject?.(err)\n this.pendingReject = null\n this.pendingResolve = null\n }\n })\n\n this.process.stdout.on('data', (chunk: Buffer) => {\n this.receiveBuffer = Buffer.concat([this.receiveBuffer, chunk])\n this._tryReceive()\n })\n\n // Give the process a moment to start up and load the model\n await new Promise<void>((resolve, reject) => {\n const timeout = setTimeout(() => resolve(), 2000)\n this.process?.on('error', (err) => {\n clearTimeout(timeout)\n reject(err)\n })\n this.process?.on('exit', (code) => {\n clearTimeout(timeout)\n if (code !== 0) {\n reject(new Error(`PythonInferenceEngine: process exited early with code ${code}`))\n }\n })\n })\n }\n\n private _tryReceive(): void {\n // Binary IPC: [4 bytes LE uint32 length][JSON bytes]\n if (this.receiveBuffer.length < 4) return\n\n const length = this.receiveBuffer.readUInt32LE(0)\n if (this.receiveBuffer.length < 4 + length) return\n\n const jsonBytes = this.receiveBuffer.subarray(4, 4 + length)\n this.receiveBuffer = this.receiveBuffer.subarray(4 + length)\n\n const resolve = this.pendingResolve\n const reject = this.pendingReject\n this.pendingResolve = null\n this.pendingReject = null\n\n if (!resolve) return\n\n try {\n const parsed = JSON.parse(jsonBytes.toString('utf8')) as Record<string, unknown>\n resolve(parsed)\n } catch (err) {\n reject?.(err instanceof Error ? err : new Error(String(err)))\n }\n }\n\n /** Send JPEG buffer, receive JSON detection results */\n async runJpeg(jpeg: Buffer): Promise<Record<string, unknown>> {\n if (!this.process?.stdin) {\n throw new Error('PythonInferenceEngine: process not initialized')\n }\n\n return new Promise<Record<string, unknown>>((resolve, reject) => {\n this.pendingResolve = resolve\n this.pendingReject = reject\n\n // Binary IPC: [4 bytes LE uint32 length][JPEG bytes]\n const lengthBuf = Buffer.allocUnsafe(4)\n lengthBuf.writeUInt32LE(jpeg.length, 0)\n this.process!.stdin!.write(Buffer.concat([lengthBuf, jpeg]))\n })\n }\n\n /** IInferenceEngine.run — wraps runJpeg for compatibility */\n async run(_input: Float32Array, _inputShape: readonly number[]): Promise<Float32Array> {\n throw new Error(\n 'PythonInferenceEngine: use runJpeg() directly — this engine operates on JPEG input',\n )\n }\n\n /** IInferenceEngine.runMultiOutput — not supported by Python engine (operates on JPEG input) */\n async runMultiOutput(\n _input: Float32Array,\n _inputShape: readonly number[],\n ): Promise<Record<string, Float32Array>> {\n throw new Error(\n 'PythonInferenceEngine: runMultiOutput() is not supported — this engine operates on JPEG input',\n )\n }\n\n async dispose(): Promise<void> {\n if (this.process) {\n this.process.stdin?.end()\n this.process.kill('SIGTERM')\n this.process = null\n }\n }\n}\n\n/**\n * Resolve Python binary for ML inference. Priority:\n * 1. Explicit config pythonPath\n * 2. Embedded (data/deps/python/bin/python3)\n * 3. System PATH (python3, python)\n * 4. Download standalone Python\n *\n * Returns null if Python is not available.\n */\nexport async function resolvePythonBinary(\n configPath: string | undefined,\n dataDir: string,\n logger: IScopedLogger,\n): Promise<string | null> {\n if (configPath) return configPath\n return ensurePython(dataDir, logger)\n}\n","// TODO: Wire PythonInferenceEngine for PyTorch/OpenVINO/TFLite runtimes\n// Currently falls back to ONNX CPU when non-ONNX runtime is requested.\n// See: packages/addon-vision/python/ for stub implementations.\n//\n// WHY THIS FILE USES RAW FILESYSTEM PATHS (modelsDir: string):\n//\n// Model files must be loaded via absolute filesystem paths because inference\n// engines (ONNX Runtime, CoreML, etc.) require direct file access -- they do\n// not accept Buffer or stream inputs. This is fundamentally different from\n// user data (recordings, media) where IAddonFileStorage abstraction makes\n// sense. Models are closer to binaries or compiled artifacts that must live\n// on the local filesystem at runtime.\n//\n// IAddonFileStorage.readFile() returns a Buffer, but onnxruntime-node's\n// InferenceSession.create() only accepts a file path string or a Uint8Array\n// loaded into memory. For large models (hundreds of MB), loading into a\n// Uint8Array is impractical. Therefore, modelsDir stays as a raw string path\n// and is intentionally NOT replaced with IAddonFileStorage here.\n\nimport type {\n IInferenceEngine,\n DetectionRuntime,\n ModelCatalogEntry,\n ModelFormat,\n IAddonModelManager,\n} from '@camstack/types'\nimport * as fs from 'node:fs'\nimport * as path from 'node:path'\nimport { NodeInferenceEngine } from './node-engine.js'\nimport { PythonInferenceEngine } from './python-engine.js'\n\nexport interface EngineResolverOptions {\n readonly runtime: DetectionRuntime | 'auto'\n readonly backend: string\n readonly modelEntry: ModelCatalogEntry\n readonly modelsDir: string\n readonly pythonPath?: string\n /** Model service for downloading models. When provided, used instead of raw filesystem probing. */\n readonly models?: IAddonModelManager\n}\n\nexport interface ResolvedEngine {\n readonly engine: IInferenceEngine\n readonly format: ModelFormat\n readonly modelPath: string\n}\n\n/** Priority order for auto-selection of ONNX backends */\nconst AUTO_BACKEND_PRIORITY = ['coreml', 'cuda', 'tensorrt', 'cpu'] as const\n\n/** Map backend names to the model format they require.\n * CoreML backend uses ONNX format -- onnxruntime-node loads the .onnx file\n * and accelerates it via the CoreML execution provider internally.\n * Native .mlpackage is only for PythonInferenceEngine. */\nconst BACKEND_TO_FORMAT: Readonly<Record<string, ModelFormat>> = {\n cpu: 'onnx',\n coreml: 'onnx',\n cuda: 'onnx',\n tensorrt: 'onnx',\n} as const\n\n/** Map DetectionRuntime to ModelFormat */\nconst RUNTIME_TO_FORMAT: Readonly<Partial<Record<DetectionRuntime, ModelFormat>>> = {\n onnx: 'onnx',\n coreml: 'coreml',\n openvino: 'openvino',\n tflite: 'tflite',\n pytorch: 'pt',\n} as const\n\nfunction modelFilePath(modelsDir: string, modelEntry: ModelCatalogEntry, format: ModelFormat): string {\n const formatEntry = modelEntry.formats[format]\n if (!formatEntry) {\n throw new Error(`Model ${modelEntry.id} has no ${format} format`)\n }\n // Derive filename from URL\n const urlParts = formatEntry.url.split('/')\n const filename = urlParts[urlParts.length - 1] ?? `${modelEntry.id}.${format}`\n return path.join(modelsDir, filename)\n}\n\nfunction modelExists(filePath: string): boolean {\n try {\n return fs.existsSync(filePath)\n } catch {\n return false\n }\n}\n\nexport async function resolveEngine(options: EngineResolverOptions): Promise<ResolvedEngine> {\n const { runtime, backend, modelEntry, modelsDir, models } = options\n\n let selectedFormat: ModelFormat\n let selectedBackend: string\n\n if (runtime === 'auto') {\n // Probe available ONNX backends and pick best\n const available = await probeOnnxBackends()\n\n // Pick first priority backend that has a corresponding model format available\n let chosen: { backend: string; format: ModelFormat } | null = null\n\n for (const b of AUTO_BACKEND_PRIORITY) {\n if (!available.includes(b)) continue\n const fmt = BACKEND_TO_FORMAT[b]\n if (!fmt) continue\n if (!modelEntry.formats[fmt]) continue\n chosen = { backend: b, format: fmt }\n break\n }\n\n if (!chosen) {\n throw new Error(\n `resolveEngine: no compatible backend found for model ${modelEntry.id}. Available backends: ${available.join(', ')}`,\n )\n }\n\n selectedFormat = chosen.format\n selectedBackend = chosen.backend\n } else {\n // Explicit runtime requested\n const fmt = RUNTIME_TO_FORMAT[runtime]\n if (!fmt) {\n throw new Error(`resolveEngine: unsupported runtime \"${runtime}\"`)\n }\n if (!modelEntry.formats[fmt]) {\n throw new Error(\n `resolveEngine: model ${modelEntry.id} has no ${fmt} format for runtime ${runtime}`,\n )\n }\n selectedFormat = fmt\n // For onnx runtime, use the provided backend; otherwise use the runtime name\n selectedBackend = runtime === 'onnx' ? (backend || 'cpu') : runtime\n }\n\n // Download model and extra files via the unified service\n let modelPath: string\n\n if (models) {\n // Use the unified ModelDownloadService\n modelPath = await models.ensure(modelEntry.id, selectedFormat)\n } else {\n // Fallback: direct filesystem check (no download capability)\n modelPath = modelFilePath(modelsDir, modelEntry, selectedFormat)\n if (!modelExists(modelPath)) {\n throw new Error(\n `resolveEngine: model file not found at ${modelPath} and no model service provided`,\n )\n }\n }\n\n // NodeInferenceEngine handles ONNX format only (with any ONNX backend including CoreML provider).\n // Native .mlpackage/.mlmodel files go to PythonInferenceEngine below.\n if (selectedFormat === 'onnx') {\n const engine = new NodeInferenceEngine(modelPath, selectedBackend)\n await engine.initialize()\n return { engine, format: selectedFormat, modelPath }\n }\n\n // For non-ONNX/CoreML formats, try PythonInferenceEngine when a python binary is available\n const { pythonPath } = options\n const PYTHON_SCRIPT_MAP: Readonly<Record<string, string>> = {\n coreml: 'coreml_inference.py',\n pytorch: 'pytorch_inference.py',\n openvino: 'openvino_inference.py',\n } as const\n\n const effectiveRuntime = runtime === 'auto' ? selectedBackend : runtime\n const scriptName = PYTHON_SCRIPT_MAP[effectiveRuntime]\n\n if (scriptName && pythonPath) {\n // Resolve python script path -- search multiple locations:\n // - src/shared/ -> ../../python/ (source development)\n // - dist/shared/ -> ../../python/ (installed addon with python/ at package root)\n // - dist/ -> ../python/ (flat dist)\n const candidates = [\n path.join(__dirname, '../../python', scriptName),\n path.join(__dirname, '../python', scriptName),\n path.join(__dirname, '../../../python', scriptName),\n ]\n const scriptPath = candidates.find(p => fs.existsSync(p))\n if (!scriptPath) {\n throw new Error(\n `resolveEngine: Python script \"${scriptName}\" not found. Searched:\\n${candidates.join('\\n')}`,\n )\n }\n const inputSize = Math.max(modelEntry.inputSize.width, modelEntry.inputSize.height)\n const engine = new PythonInferenceEngine(pythonPath, scriptPath, effectiveRuntime as DetectionRuntime, modelPath, [\n `--input-size=${inputSize}`,\n `--confidence=0.25`,\n ])\n await engine.initialize()\n return { engine, format: selectedFormat, modelPath }\n }\n\n // Final fallback: use ONNX CPU if available\n const fallbackPath = modelFilePath(modelsDir, modelEntry, 'onnx')\n if (modelEntry.formats['onnx'] && modelExists(fallbackPath)) {\n const engine = new NodeInferenceEngine(fallbackPath, 'cpu')\n await engine.initialize()\n return { engine, format: 'onnx', modelPath: fallbackPath }\n }\n\n throw new Error(\n `resolveEngine: format ${selectedFormat} is not yet supported by NodeInferenceEngine, ` +\n `no Python runtime is available, and no ONNX fallback exists`,\n )\n}\n\n/** Probe which ONNX execution providers are available on this system */\nexport async function probeOnnxBackends(): Promise<string[]> {\n const available: string[] = ['cpu'] // CPU is always available\n\n try {\n const ort = await import('onnxruntime-node')\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const providers: string[] = (ort as any).env?.webgl?.disabled !== undefined\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ? ((ort as any).InferenceSession?.getAvailableProviders?.() ?? [])\n : []\n\n for (const p of providers) {\n const normalized = p.toLowerCase().replace('executionprovider', '')\n if (normalized === 'coreml') available.push('coreml')\n else if (normalized === 'cuda') available.push('cuda')\n else if (normalized === 'tensorrt') available.push('tensorrt')\n }\n } catch {\n // onnxruntime-node may not be installed; CPU only\n }\n\n // Platform-specific hints when getAvailableProviders isn't exposed\n if (process.platform === 'darwin' && !available.includes('coreml')) {\n available.push('coreml')\n }\n\n return [...new Set(available)]\n}\n"],"mappings":";AACA,YAAY,UAAU;AAEtB,IAAM,sBAAwD;AAAA,EAC5D,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,UAAU;AAAA,EACV,KAAK;AACP;AAEA,IAAM,oBAA+D;AAAA,EACnE,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,UAAU;AACZ;AAEO,IAAM,sBAAN,MAAsD;AAAA,EAK3D,YACmB,WACA,SACjB;AAFiB;AACA;AAEjB,SAAK,SAAU,kBAAkB,OAAO,KAAK;AAAA,EAC/C;AAAA,EATS,UAA4B;AAAA,EAC5B;AAAA,EACD,UAAmB;AAAA,EAS3B,MAAM,aAA4B;AAChC,UAAM,MAAM,MAAM,OAAO,kBAAkB;AAC3C,UAAM,WAAW,oBAAoB,KAAK,OAAO,KAAK;AAGtD,UAAM,eAAoB,gBAAW,KAAK,SAAS,IAC/C,KAAK,YACA,aAAQ,QAAQ,IAAI,GAAG,KAAK,SAAS;AAE9C,UAAM,iBAA0C;AAAA,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,IAAI;AAAA,IACR,yBAAyB,cAAc;AAAA,EAEzC;AACF;AAGA,eAAsB,oBAAuC;AAC3D,QAAM,YAAsB,CAAC,KAAK;AAElC,MAAI;AACF,UAAM,MAAM,MAAM,OAAO,kBAAkB;AAE3C,UAAM,YAAuB,IAAY,KAAK,OAAO,aAAa,SAE5D,IAAY,kBAAkB,wBAAwB,KAAK,CAAC,IAC9D,CAAC;AAEL,eAAW,KAAK,WAAW;AACzB,YAAM,aAAa,EAAE,YAAY,EAAE,QAAQ,qBAAqB,EAAE;AAClE,UAAI,eAAe,SAAU,WAAU,KAAK,QAAQ;AAAA,eAC3C,eAAe,OAAQ,WAAU,KAAK,MAAM;AAAA,eAC5C,eAAe,WAAY,WAAU,KAAK,UAAU;AAAA,IAC/D;AAAA,EACF,QAAQ;AAAA,EAER;AAGA,MAAI,QAAQ,aAAa,YAAY,CAAC,UAAU,SAAS,QAAQ,GAAG;AAClE,cAAU,KAAK,QAAQ;AAAA,EACzB;AAEA,SAAO,CAAC,GAAG,IAAI,IAAI,SAAS,CAAC;AAC/B;","names":["resolve","path"]}
@@ -1,36 +0,0 @@
1
- import {
2
- MLPACKAGE_FILES
3
- } from "./chunk-BP7H4NFS.mjs";
4
-
5
- // src/catalogs/segmentation-refiner-models.ts
6
- import { hfModelUrl } from "@camstack/types";
7
- var HF_REPO = "camstack/camstack-models";
8
- var hf = (path) => hfModelUrl(HF_REPO, path);
9
- var MASK_LABELS = [
10
- { id: "mask", name: "Segmentation Mask" }
11
- ];
12
- var SEGMENTATION_REFINER_MODELS = [
13
- {
14
- id: "u2netp",
15
- name: "U2-Net Portable",
16
- description: "U2-Net-P \u2014 ultra-lightweight salient object segmentation (4.7 MB), no prompt needed",
17
- inputSize: { width: 320, height: 320 },
18
- labels: MASK_LABELS,
19
- formats: {
20
- onnx: { url: hf("segmentationRefiner/u2netp/onnx/camstack-u2netp.onnx"), sizeMB: 5 },
21
- coreml: {
22
- url: hf("segmentationRefiner/u2netp/coreml/camstack-u2netp.mlpackage"),
23
- sizeMB: 3,
24
- isDirectory: true,
25
- files: MLPACKAGE_FILES,
26
- runtimes: ["python"]
27
- }
28
- // OpenVINO: not yet converted
29
- }
30
- }
31
- ];
32
-
33
- export {
34
- SEGMENTATION_REFINER_MODELS
35
- };
36
- //# sourceMappingURL=chunk-7DYHXUPZ.mjs.map
@@ -1,11 +0,0 @@
1
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
- }) : x)(function(x) {
4
- if (typeof require !== "undefined") return require.apply(this, arguments);
5
- throw Error('Dynamic require of "' + x + '" is not supported');
6
- });
7
-
8
- export {
9
- __require
10
- };
11
- //# sourceMappingURL=chunk-BJTO5JO5.mjs.map