@camstack/types 1.0.7 → 1.1.1

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.
@@ -1,57 +1,187 @@
1
- import type { LabelDefinition, ClassMapDefinition } from './labels.js';
1
+ import { z } from 'zod';
2
+ import type { ClassMapDefinition, LabelDefinition } from './labels.js';
2
3
  export declare const MODEL_FORMATS: readonly ["onnx", "coreml", "openvino", "tflite", "pt"];
3
4
  export type ModelFormat = (typeof MODEL_FORMATS)[number];
4
5
  export type ModelOutputFormat = 'yolo' | 'ssd' | 'embedding' | 'classification' | 'ocr' | 'segmentation';
5
- export interface ModelFormatEntry {
6
- readonly url: string;
7
- readonly sizeMB: number;
8
- /** Whether this format is a directory bundle (e.g., .mlpackage) rather than a single file */
9
- readonly isDirectory?: boolean;
10
- /**
11
- * For directory formats: list of files relative to the directory root.
12
- * The downloader fetches each file from `{url}/{file}` and saves to `{modelDir}/{file}`.
13
- * If omitted for a directory format, the downloader probes HuggingFace API (slower).
14
- */
15
- readonly files?: readonly string[];
16
- /** Runtime(s) that can use this format. If omitted, inferred from ModelFormat key */
17
- readonly runtimes?: readonly ('node' | 'python')[];
18
- }
6
+ /**
7
+ * Multi-file format payload.
8
+ *
9
+ * - Directory formats (`isDirectory: true`, e.g. `.mlpackage`): files
10
+ * relative to the directory root — the downloader fetches each from
11
+ * `{url}/{file}` into `{modelDir}/{file}`. If omitted, it probes the
12
+ * HuggingFace API (slower).
13
+ * - Single-file formats (no `isDirectory`, e.g. OpenVINO IR): sibling
14
+ * files fetched from the SAME remote directory as `url` and stored flat
15
+ * alongside the main file — e.g. `['camstack-yolov9t.bin']` for the IR
16
+ * weights next to `camstack-yolov9t.xml`.
17
+ */
18
+ export declare const ModelFormatEntrySchema: z.ZodObject<{
19
+ url: z.ZodString;
20
+ sizeMB: z.ZodNumber;
21
+ isDirectory: z.ZodOptional<z.ZodBoolean>;
22
+ files: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
23
+ runtimes: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodEnum<{
24
+ node: "node";
25
+ python: "python";
26
+ }>>>>;
27
+ }, z.core.$strip>;
28
+ export type ModelFormatEntry = z.infer<typeof ModelFormatEntrySchema>;
19
29
  /**
20
30
  * Extra file that must be downloaded alongside the model (e.g., labels JSON, dict.txt).
21
31
  * The downloader fetches from `url` and saves to `{modelsDir}/{filename}`.
22
32
  */
23
- export interface ModelExtraFile {
24
- readonly url: string;
25
- readonly filename: string;
26
- readonly sizeMB: number;
27
- }
28
- export interface ModelCatalogEntry {
29
- readonly id: string;
30
- readonly name: string;
31
- readonly description: string;
32
- readonly formats: Partial<Readonly<Record<ModelFormat, ModelFormatEntry>>>;
33
- readonly inputSize: {
34
- readonly width: number;
35
- readonly height: number;
36
- };
37
- readonly labels: readonly LabelDefinition[];
38
- readonly inputLayout?: 'nchw' | 'nhwc';
39
- readonly inputNormalization?: 'zero-one' | 'imagenet' | 'none';
40
- readonly preprocessMode?: 'letterbox' | 'resize';
41
- /**
42
- * When true, the executor produces a landmark-aligned crop (similarity warp
43
- * onto the canonical template) before this step runs, instead of a plain
44
- * axis-aligned bbox crop. Required for face-recognition embedders (ArcFace):
45
- * their embeddings are only discriminative on an aligned input. The face
46
- * detector that produced the parent detail must emit 5 landmarks.
47
- */
48
- readonly faceAlignment?: boolean;
49
- /**
50
- * Auxiliary files required at runtime (labels JSON, charset dict, etc.).
51
- * Downloaded into the same modelsDir alongside the model file.
52
- */
53
- readonly extraFiles?: readonly ModelExtraFile[];
54
- }
33
+ export declare const ModelExtraFileSchema: z.ZodObject<{
34
+ url: z.ZodString;
35
+ filename: z.ZodString;
36
+ sizeMB: z.ZodNumber;
37
+ }, z.core.$strip>;
38
+ export type ModelExtraFile = z.infer<typeof ModelExtraFileSchema>;
39
+ /**
40
+ * Per-format payload map. Modelled as an explicit object (one optional key
41
+ * per `ModelFormat`) rather than `z.record(enum, …)` — zod v4's enum-keyed
42
+ * record requires every key, but a catalog entry only ships a subset of
43
+ * formats.
44
+ */
45
+ export declare const ModelFormatsSchema: z.ZodObject<{
46
+ onnx: z.ZodOptional<z.ZodObject<{
47
+ url: z.ZodString;
48
+ sizeMB: z.ZodNumber;
49
+ isDirectory: z.ZodOptional<z.ZodBoolean>;
50
+ files: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
51
+ runtimes: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodEnum<{
52
+ node: "node";
53
+ python: "python";
54
+ }>>>>;
55
+ }, z.core.$strip>>;
56
+ coreml: z.ZodOptional<z.ZodObject<{
57
+ url: z.ZodString;
58
+ sizeMB: z.ZodNumber;
59
+ isDirectory: z.ZodOptional<z.ZodBoolean>;
60
+ files: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
61
+ runtimes: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodEnum<{
62
+ node: "node";
63
+ python: "python";
64
+ }>>>>;
65
+ }, z.core.$strip>>;
66
+ openvino: z.ZodOptional<z.ZodObject<{
67
+ url: z.ZodString;
68
+ sizeMB: z.ZodNumber;
69
+ isDirectory: z.ZodOptional<z.ZodBoolean>;
70
+ files: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
71
+ runtimes: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodEnum<{
72
+ node: "node";
73
+ python: "python";
74
+ }>>>>;
75
+ }, z.core.$strip>>;
76
+ tflite: z.ZodOptional<z.ZodObject<{
77
+ url: z.ZodString;
78
+ sizeMB: z.ZodNumber;
79
+ isDirectory: z.ZodOptional<z.ZodBoolean>;
80
+ files: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
81
+ runtimes: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodEnum<{
82
+ node: "node";
83
+ python: "python";
84
+ }>>>>;
85
+ }, z.core.$strip>>;
86
+ pt: z.ZodOptional<z.ZodObject<{
87
+ url: z.ZodString;
88
+ sizeMB: z.ZodNumber;
89
+ isDirectory: z.ZodOptional<z.ZodBoolean>;
90
+ files: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
91
+ runtimes: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodEnum<{
92
+ node: "node";
93
+ python: "python";
94
+ }>>>>;
95
+ }, z.core.$strip>>;
96
+ }, z.core.$strip>;
97
+ export declare const ModelCatalogEntrySchema: z.ZodObject<{
98
+ id: z.ZodString;
99
+ name: z.ZodString;
100
+ description: z.ZodString;
101
+ formats: z.ZodObject<{
102
+ onnx: z.ZodOptional<z.ZodObject<{
103
+ url: z.ZodString;
104
+ sizeMB: z.ZodNumber;
105
+ isDirectory: z.ZodOptional<z.ZodBoolean>;
106
+ files: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
107
+ runtimes: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodEnum<{
108
+ node: "node";
109
+ python: "python";
110
+ }>>>>;
111
+ }, z.core.$strip>>;
112
+ coreml: z.ZodOptional<z.ZodObject<{
113
+ url: z.ZodString;
114
+ sizeMB: z.ZodNumber;
115
+ isDirectory: z.ZodOptional<z.ZodBoolean>;
116
+ files: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
117
+ runtimes: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodEnum<{
118
+ node: "node";
119
+ python: "python";
120
+ }>>>>;
121
+ }, z.core.$strip>>;
122
+ openvino: z.ZodOptional<z.ZodObject<{
123
+ url: z.ZodString;
124
+ sizeMB: z.ZodNumber;
125
+ isDirectory: z.ZodOptional<z.ZodBoolean>;
126
+ files: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
127
+ runtimes: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodEnum<{
128
+ node: "node";
129
+ python: "python";
130
+ }>>>>;
131
+ }, z.core.$strip>>;
132
+ tflite: z.ZodOptional<z.ZodObject<{
133
+ url: z.ZodString;
134
+ sizeMB: z.ZodNumber;
135
+ isDirectory: z.ZodOptional<z.ZodBoolean>;
136
+ files: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
137
+ runtimes: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodEnum<{
138
+ node: "node";
139
+ python: "python";
140
+ }>>>>;
141
+ }, z.core.$strip>>;
142
+ pt: z.ZodOptional<z.ZodObject<{
143
+ url: z.ZodString;
144
+ sizeMB: z.ZodNumber;
145
+ isDirectory: z.ZodOptional<z.ZodBoolean>;
146
+ files: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
147
+ runtimes: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodEnum<{
148
+ node: "node";
149
+ python: "python";
150
+ }>>>>;
151
+ }, z.core.$strip>>;
152
+ }, z.core.$strip>;
153
+ inputSize: z.ZodObject<{
154
+ width: z.ZodNumber;
155
+ height: z.ZodNumber;
156
+ }, z.core.$strip>;
157
+ labels: z.ZodReadonly<z.ZodArray<z.ZodObject<{
158
+ id: z.ZodString;
159
+ name: z.ZodString;
160
+ category: z.ZodOptional<z.ZodString>;
161
+ description: z.ZodOptional<z.ZodString>;
162
+ icon: z.ZodOptional<z.ZodString>;
163
+ }, z.core.$strip>>>;
164
+ inputLayout: z.ZodOptional<z.ZodEnum<{
165
+ nchw: "nchw";
166
+ nhwc: "nhwc";
167
+ }>>;
168
+ inputNormalization: z.ZodOptional<z.ZodEnum<{
169
+ "zero-one": "zero-one";
170
+ imagenet: "imagenet";
171
+ none: "none";
172
+ }>>;
173
+ preprocessMode: z.ZodOptional<z.ZodEnum<{
174
+ letterbox: "letterbox";
175
+ resize: "resize";
176
+ }>>;
177
+ faceAlignment: z.ZodOptional<z.ZodBoolean>;
178
+ extraFiles: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodObject<{
179
+ url: z.ZodString;
180
+ filename: z.ZodString;
181
+ sizeMB: z.ZodNumber;
182
+ }, z.core.$strip>>>>;
183
+ }, z.core.$strip>;
184
+ export type ModelCatalogEntry = z.infer<typeof ModelCatalogEntrySchema>;
55
185
  export interface DetectionModel {
56
186
  readonly id: string;
57
187
  readonly name: string;
@@ -86,3 +216,174 @@ export interface CustomModelMetadata {
86
216
  readonly inputNormalization?: 'zero-one' | 'imagenet' | 'none';
87
217
  readonly outputFormat: ModelOutputFormat;
88
218
  }
219
+ export declare const ConvertTargetSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
220
+ format: z.ZodLiteral<"openvino">;
221
+ precisions: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
222
+ fp16: "fp16";
223
+ int8: "int8";
224
+ }>>>;
225
+ }, z.core.$strip>, z.ZodObject<{
226
+ format: z.ZodLiteral<"coreml">;
227
+ }, z.core.$strip>], "format">;
228
+ export type ConvertTarget = z.infer<typeof ConvertTargetSchema>;
229
+ export declare const ModelConvertMetadataSchema: z.ZodObject<{
230
+ id: z.ZodString;
231
+ name: z.ZodString;
232
+ labels: z.ZodReadonly<z.ZodArray<z.ZodObject<{
233
+ id: z.ZodString;
234
+ name: z.ZodString;
235
+ category: z.ZodOptional<z.ZodString>;
236
+ description: z.ZodOptional<z.ZodString>;
237
+ icon: z.ZodOptional<z.ZodString>;
238
+ }, z.core.$strip>>>;
239
+ inputSize: z.ZodObject<{
240
+ width: z.ZodNumber;
241
+ height: z.ZodNumber;
242
+ }, z.core.$strip>;
243
+ inputLayout: z.ZodOptional<z.ZodEnum<{
244
+ nchw: "nchw";
245
+ nhwc: "nhwc";
246
+ }>>;
247
+ inputNormalization: z.ZodOptional<z.ZodEnum<{
248
+ "zero-one": "zero-one";
249
+ imagenet: "imagenet";
250
+ none: "none";
251
+ }>>;
252
+ preprocessMode: z.ZodOptional<z.ZodEnum<{
253
+ letterbox: "letterbox";
254
+ resize: "resize";
255
+ }>>;
256
+ outputFormat: z.ZodEnum<{
257
+ yolo: "yolo";
258
+ ssd: "ssd";
259
+ embedding: "embedding";
260
+ classification: "classification";
261
+ ocr: "ocr";
262
+ segmentation: "segmentation";
263
+ }>;
264
+ faceAlignment: z.ZodOptional<z.ZodBoolean>;
265
+ }, z.core.$strip>;
266
+ export type ModelConvertMetadata = z.infer<typeof ModelConvertMetadataSchema>;
267
+ export declare const ConvertArtifactSchema: z.ZodObject<{
268
+ format: z.ZodEnum<{
269
+ onnx: "onnx";
270
+ coreml: "coreml";
271
+ openvino: "openvino";
272
+ tflite: "tflite";
273
+ pt: "pt";
274
+ }>;
275
+ precision: z.ZodOptional<z.ZodEnum<{
276
+ fp16: "fp16";
277
+ int8: "int8";
278
+ }>>;
279
+ sizeMB: z.ZodNumber;
280
+ validated: z.ZodBoolean;
281
+ files: z.ZodReadonly<z.ZodArray<z.ZodString>>;
282
+ }, z.core.$strip>;
283
+ export type ConvertArtifact = z.infer<typeof ConvertArtifactSchema>;
284
+ export declare const ConvertResultSchema: z.ZodObject<{
285
+ entry: z.ZodObject<{
286
+ id: z.ZodString;
287
+ name: z.ZodString;
288
+ description: z.ZodString;
289
+ formats: z.ZodObject<{
290
+ onnx: z.ZodOptional<z.ZodObject<{
291
+ url: z.ZodString;
292
+ sizeMB: z.ZodNumber;
293
+ isDirectory: z.ZodOptional<z.ZodBoolean>;
294
+ files: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
295
+ runtimes: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodEnum<{
296
+ node: "node";
297
+ python: "python";
298
+ }>>>>;
299
+ }, z.core.$strip>>;
300
+ coreml: z.ZodOptional<z.ZodObject<{
301
+ url: z.ZodString;
302
+ sizeMB: z.ZodNumber;
303
+ isDirectory: z.ZodOptional<z.ZodBoolean>;
304
+ files: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
305
+ runtimes: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodEnum<{
306
+ node: "node";
307
+ python: "python";
308
+ }>>>>;
309
+ }, z.core.$strip>>;
310
+ openvino: z.ZodOptional<z.ZodObject<{
311
+ url: z.ZodString;
312
+ sizeMB: z.ZodNumber;
313
+ isDirectory: z.ZodOptional<z.ZodBoolean>;
314
+ files: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
315
+ runtimes: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodEnum<{
316
+ node: "node";
317
+ python: "python";
318
+ }>>>>;
319
+ }, z.core.$strip>>;
320
+ tflite: z.ZodOptional<z.ZodObject<{
321
+ url: z.ZodString;
322
+ sizeMB: z.ZodNumber;
323
+ isDirectory: z.ZodOptional<z.ZodBoolean>;
324
+ files: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
325
+ runtimes: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodEnum<{
326
+ node: "node";
327
+ python: "python";
328
+ }>>>>;
329
+ }, z.core.$strip>>;
330
+ pt: z.ZodOptional<z.ZodObject<{
331
+ url: z.ZodString;
332
+ sizeMB: z.ZodNumber;
333
+ isDirectory: z.ZodOptional<z.ZodBoolean>;
334
+ files: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
335
+ runtimes: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodEnum<{
336
+ node: "node";
337
+ python: "python";
338
+ }>>>>;
339
+ }, z.core.$strip>>;
340
+ }, z.core.$strip>;
341
+ inputSize: z.ZodObject<{
342
+ width: z.ZodNumber;
343
+ height: z.ZodNumber;
344
+ }, z.core.$strip>;
345
+ labels: z.ZodReadonly<z.ZodArray<z.ZodObject<{
346
+ id: z.ZodString;
347
+ name: z.ZodString;
348
+ category: z.ZodOptional<z.ZodString>;
349
+ description: z.ZodOptional<z.ZodString>;
350
+ icon: z.ZodOptional<z.ZodString>;
351
+ }, z.core.$strip>>>;
352
+ inputLayout: z.ZodOptional<z.ZodEnum<{
353
+ nchw: "nchw";
354
+ nhwc: "nhwc";
355
+ }>>;
356
+ inputNormalization: z.ZodOptional<z.ZodEnum<{
357
+ "zero-one": "zero-one";
358
+ imagenet: "imagenet";
359
+ none: "none";
360
+ }>>;
361
+ preprocessMode: z.ZodOptional<z.ZodEnum<{
362
+ letterbox: "letterbox";
363
+ resize: "resize";
364
+ }>>;
365
+ faceAlignment: z.ZodOptional<z.ZodBoolean>;
366
+ extraFiles: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodObject<{
367
+ url: z.ZodString;
368
+ filename: z.ZodString;
369
+ sizeMB: z.ZodNumber;
370
+ }, z.core.$strip>>>>;
371
+ }, z.core.$strip>;
372
+ artifacts: z.ZodReadonly<z.ZodArray<z.ZodObject<{
373
+ format: z.ZodEnum<{
374
+ onnx: "onnx";
375
+ coreml: "coreml";
376
+ openvino: "openvino";
377
+ tflite: "tflite";
378
+ pt: "pt";
379
+ }>;
380
+ precision: z.ZodOptional<z.ZodEnum<{
381
+ fp16: "fp16";
382
+ int8: "int8";
383
+ }>>;
384
+ sizeMB: z.ZodNumber;
385
+ validated: z.ZodBoolean;
386
+ files: z.ZodReadonly<z.ZodArray<z.ZodString>>;
387
+ }, z.core.$strip>>>;
388
+ }, z.core.$strip>;
389
+ export type ConvertResult = z.infer<typeof ConvertResultSchema>;
@@ -136,6 +136,8 @@ export interface MaskOutput {
136
136
  readonly mask: string;
137
137
  readonly maskWidth: number;
138
138
  readonly maskHeight: number;
139
+ /** Largest-connected-component bbox in mask-pixel space [x, y, w, h]. */
140
+ readonly maskBbox?: readonly [number, number, number, number];
139
141
  }
140
142
  /** Discriminated union for step output — use switch(output.kind) */
141
143
  export type StepOutput = DetectionsOutput | ClassificationsOutput | EmbeddingOutput | TextOutput | MaskOutput;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/types",
3
- "version": "1.0.7",
3
+ "version": "1.1.1",
4
4
  "description": "Shared types, interfaces, and model catalogs for the CamStack detection ecosystem",
5
5
  "keywords": [
6
6
  "camstack",