@mauriciobenjamin700/ort-vision-sdk-web 0.2.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.
Files changed (72) hide show
  1. package/CHANGELOG.md +128 -0
  2. package/LICENSE +21 -0
  3. package/README.md +90 -0
  4. package/dist/core/canvas.d.ts +21 -0
  5. package/dist/core/canvas.d.ts.map +1 -0
  6. package/dist/core/canvas.js +58 -0
  7. package/dist/core/canvas.js.map +1 -0
  8. package/dist/core/exceptions.d.ts +25 -0
  9. package/dist/core/exceptions.d.ts.map +1 -0
  10. package/dist/core/exceptions.js +28 -0
  11. package/dist/core/exceptions.js.map +1 -0
  12. package/dist/core/providers.d.ts +21 -0
  13. package/dist/core/providers.d.ts.map +1 -0
  14. package/dist/core/providers.js +29 -0
  15. package/dist/core/providers.js.map +1 -0
  16. package/dist/core/session.d.ts +47 -0
  17. package/dist/core/session.d.ts.map +1 -0
  18. package/dist/core/session.js +86 -0
  19. package/dist/core/session.js.map +1 -0
  20. package/dist/index.d.ts +21 -0
  21. package/dist/index.d.ts.map +1 -0
  22. package/dist/index.js +21 -0
  23. package/dist/index.js.map +1 -0
  24. package/dist/io/image.d.ts +17 -0
  25. package/dist/io/image.d.ts.map +1 -0
  26. package/dist/io/image.js +104 -0
  27. package/dist/io/image.js.map +1 -0
  28. package/dist/labels.d.ts +38 -0
  29. package/dist/labels.d.ts.map +1 -0
  30. package/dist/labels.js +71 -0
  31. package/dist/labels.js.map +1 -0
  32. package/dist/postprocess/classification.d.ts +16 -0
  33. package/dist/postprocess/classification.d.ts.map +1 -0
  34. package/dist/postprocess/classification.js +46 -0
  35. package/dist/postprocess/classification.js.map +1 -0
  36. package/dist/postprocess/detection.d.ts +112 -0
  37. package/dist/postprocess/detection.d.ts.map +1 -0
  38. package/dist/postprocess/detection.js +283 -0
  39. package/dist/postprocess/detection.js.map +1 -0
  40. package/dist/postprocess/segmentation.d.ts +61 -0
  41. package/dist/postprocess/segmentation.d.ts.map +1 -0
  42. package/dist/postprocess/segmentation.js +184 -0
  43. package/dist/postprocess/segmentation.js.map +1 -0
  44. package/dist/preprocess/image.d.ts +71 -0
  45. package/dist/preprocess/image.d.ts.map +1 -0
  46. package/dist/preprocess/image.js +171 -0
  47. package/dist/preprocess/image.js.map +1 -0
  48. package/dist/results.d.ts +182 -0
  49. package/dist/results.d.ts.map +1 -0
  50. package/dist/results.js +321 -0
  51. package/dist/results.js.map +1 -0
  52. package/dist/tasks/base.d.ts +14 -0
  53. package/dist/tasks/base.d.ts.map +1 -0
  54. package/dist/tasks/base.js +17 -0
  55. package/dist/tasks/base.js.map +1 -0
  56. package/dist/tasks/classifier.d.ts +82 -0
  57. package/dist/tasks/classifier.d.ts.map +1 -0
  58. package/dist/tasks/classifier.js +135 -0
  59. package/dist/tasks/classifier.js.map +1 -0
  60. package/dist/tasks/detector.d.ts +102 -0
  61. package/dist/tasks/detector.d.ts.map +1 -0
  62. package/dist/tasks/detector.js +189 -0
  63. package/dist/tasks/detector.js.map +1 -0
  64. package/dist/tasks/segmenter.d.ts +105 -0
  65. package/dist/tasks/segmenter.d.ts.map +1 -0
  66. package/dist/tasks/segmenter.js +242 -0
  67. package/dist/tasks/segmenter.js.map +1 -0
  68. package/dist/types.d.ts +182 -0
  69. package/dist/types.d.ts.map +1 -0
  70. package/dist/types.js +147 -0
  71. package/dist/types.js.map +1 -0
  72. package/package.json +71 -0
package/dist/index.js ADDED
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @ort-vision-sdk/web — high-level TypeScript SDK for browser computer
3
+ * vision inference with ONNX Runtime Web.
4
+ */
5
+ export { BoundingBox, Mask, RGBImage, } from "./types.js";
6
+ export { Boxes, ClassificationResults, DetectionResults, Masks, Probs, SegmentationResults, } from "./results.js";
7
+ export { COCO_CLASSES, resolveLabels, } from "./labels.js";
8
+ export { ImageLoadError, InferenceError, LabelMapError, ModelLoadError, OrtVisionError, ProviderNotAvailableError, } from "./core/exceptions.js";
9
+ export { OrtSession, } from "./core/session.js";
10
+ export { DEFAULT_PROVIDERS, resolveProviders } from "./core/providers.js";
11
+ export { loadImage } from "./io/image.js";
12
+ export { fromCv2, letterbox, normalize, resize, toCHW, toCv2, toFloat32, toFloat32Tensor, toTensor, } from "./preprocess/image.js";
13
+ export { softmax, topK, } from "./postprocess/classification.js";
14
+ export { batchedNms, decodeYolo, decodeYoloAnchors, decodeYoloV8, decodeYoloV8Anchors, nms, } from "./postprocess/detection.js";
15
+ export { decodeYoloSeg, decodeYoloV8Seg, } from "./postprocess/segmentation.js";
16
+ export { VisionTask } from "./tasks/base.js";
17
+ export { Classifier, } from "./tasks/classifier.js";
18
+ export { Detector, } from "./tasks/detector.js";
19
+ export { Segmenter, } from "./tasks/segmenter.js";
20
+ export const VERSION = "0.2.1";
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,WAAW,EACX,IAAI,EACJ,QAAQ,GAKT,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,KAAK,EACL,qBAAqB,EACrB,gBAAgB,EAChB,KAAK,EACL,KAAK,EACL,mBAAmB,GACpB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,YAAY,EAGZ,aAAa,GACd,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,cAAc,EACd,cAAc,EACd,aAAa,EACb,cAAc,EACd,cAAc,EACd,yBAAyB,GAC1B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAGL,UAAU,GACX,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE1E,OAAO,EAAmB,SAAS,EAAE,MAAM,eAAe,CAAC;AAE3D,OAAO,EAEL,OAAO,EACP,SAAS,EACT,SAAS,EACT,MAAM,EACN,KAAK,EACL,KAAK,EACL,SAAS,EACT,eAAe,EACf,QAAQ,GACT,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAEL,OAAO,EACP,IAAI,GACL,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAOL,UAAU,EACV,UAAU,EACV,iBAAiB,EACjB,YAAY,EACZ,mBAAmB,EACnB,GAAG,GACJ,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAIL,aAAa,EACb,eAAe,GAChB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAGL,UAAU,GACX,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAIL,QAAQ,GACT,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAIL,SAAS,GACV,MAAM,sBAAsB,CAAC;AAE9B,MAAM,CAAC,MAAM,OAAO,GAAW,OAAO,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Image loading utilities — convert any supported source into the canonical
3
+ * {@link RGBImage} format.
4
+ *
5
+ * Browser-only: uses `fetch`, `createImageBitmap`, and a Canvas 2D context to
6
+ * decode arbitrary inputs into a tightly-packed `Uint8Array` of HWC RGB pixels.
7
+ */
8
+ import { RGBImage } from "../types.js";
9
+ /** Anything {@link loadImage} accepts as an image input. */
10
+ export type ImageInput = string | Blob | HTMLImageElement | HTMLCanvasElement | OffscreenCanvas | ImageBitmap | ImageData | RGBImage;
11
+ /**
12
+ * Load an image from any supported source into a HWC uint8 RGB array.
13
+ *
14
+ * @throws {@link ImageLoadError} if the source cannot be decoded or has an unsupported shape.
15
+ */
16
+ export declare function loadImage(source: ImageInput): Promise<RGBImage>;
17
+ //# sourceMappingURL=image.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../src/io/image.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAQH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,4DAA4D;AAC5D,MAAM,MAAM,UAAU,GAClB,MAAM,GACN,IAAI,GACJ,gBAAgB,GAChB,iBAAiB,GACjB,eAAe,GACf,WAAW,GACX,SAAS,GACT,QAAQ,CAAC;AAEb;;;;GAIG;AACH,wBAAsB,SAAS,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,QAAQ,CAAC,CAqCrE"}
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Image loading utilities — convert any supported source into the canonical
3
+ * {@link RGBImage} format.
4
+ *
5
+ * Browser-only: uses `fetch`, `createImageBitmap`, and a Canvas 2D context to
6
+ * decode arbitrary inputs into a tightly-packed `Uint8Array` of HWC RGB pixels.
7
+ */
8
+ import { createCanvas, get2DContext, imageDataToRGB, } from "../core/canvas.js";
9
+ import { ImageLoadError } from "../core/exceptions.js";
10
+ import { RGBImage } from "../types.js";
11
+ /**
12
+ * Load an image from any supported source into a HWC uint8 RGB array.
13
+ *
14
+ * @throws {@link ImageLoadError} if the source cannot be decoded or has an unsupported shape.
15
+ */
16
+ export async function loadImage(source) {
17
+ if (source instanceof RGBImage) {
18
+ return source;
19
+ }
20
+ if (typeof ImageData !== "undefined" && source instanceof ImageData) {
21
+ return imageDataToRGB(source);
22
+ }
23
+ if (typeof source === "string") {
24
+ return loadFromUrl(source);
25
+ }
26
+ if (typeof Blob !== "undefined" && source instanceof Blob) {
27
+ return loadFromBlob(source);
28
+ }
29
+ if (typeof HTMLImageElement !== "undefined" && source instanceof HTMLImageElement) {
30
+ await waitForImageElement(source);
31
+ return drawableToRGB(source, source.naturalWidth, source.naturalHeight);
32
+ }
33
+ if (typeof HTMLCanvasElement !== "undefined" && source instanceof HTMLCanvasElement) {
34
+ return drawableToRGB(source, source.width, source.height);
35
+ }
36
+ if (typeof OffscreenCanvas !== "undefined" && source instanceof OffscreenCanvas) {
37
+ return drawableToRGB(source, source.width, source.height);
38
+ }
39
+ if (typeof ImageBitmap !== "undefined" && source instanceof ImageBitmap) {
40
+ return drawableToRGB(source, source.width, source.height);
41
+ }
42
+ throw new ImageLoadError(`Unsupported image source type: ${Object.prototype.toString.call(source)}`);
43
+ }
44
+ async function loadFromUrl(url) {
45
+ let response;
46
+ try {
47
+ response = await fetch(url);
48
+ }
49
+ catch (err) {
50
+ throw new ImageLoadError(`Failed to fetch image from ${url}: ${err.message}`, { cause: err });
51
+ }
52
+ if (!response.ok) {
53
+ throw new ImageLoadError(`Failed to fetch image from ${url}: HTTP ${response.status} ${response.statusText}`);
54
+ }
55
+ const blob = await response.blob();
56
+ return loadFromBlob(blob);
57
+ }
58
+ async function loadFromBlob(blob) {
59
+ let bitmap;
60
+ try {
61
+ bitmap = await createImageBitmap(blob);
62
+ }
63
+ catch (err) {
64
+ throw new ImageLoadError(`Failed to decode image blob: ${err.message}`, { cause: err });
65
+ }
66
+ try {
67
+ return drawableToRGB(bitmap, bitmap.width, bitmap.height);
68
+ }
69
+ finally {
70
+ bitmap.close();
71
+ }
72
+ }
73
+ function waitForImageElement(img) {
74
+ if (img.complete && img.naturalWidth > 0) {
75
+ return Promise.resolve();
76
+ }
77
+ return new Promise((resolve, reject) => {
78
+ const onLoad = () => {
79
+ cleanup();
80
+ resolve();
81
+ };
82
+ const onError = () => {
83
+ cleanup();
84
+ reject(new ImageLoadError("Failed to load HTMLImageElement (load event errored)"));
85
+ };
86
+ const cleanup = () => {
87
+ img.removeEventListener("load", onLoad);
88
+ img.removeEventListener("error", onError);
89
+ };
90
+ img.addEventListener("load", onLoad, { once: true });
91
+ img.addEventListener("error", onError, { once: true });
92
+ });
93
+ }
94
+ function drawableToRGB(drawable, width, height) {
95
+ if (width === 0 || height === 0) {
96
+ throw new ImageLoadError(`Cannot load image with zero dimension (${width}x${height}).`);
97
+ }
98
+ const canvas = createCanvas(width, height);
99
+ const ctx = get2DContext(canvas);
100
+ ctx.drawImage(drawable, 0, 0);
101
+ const imageData = ctx.getImageData(0, 0, width, height);
102
+ return imageDataToRGB(imageData);
103
+ }
104
+ //# sourceMappingURL=image.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"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AAC,EAAE,CAAC;QAChC,MAAM,IAAI,cAAc,CAAC,0CAA0C,KAAK,IAAI,MAAM,IAAI,CAAC,CAAC;IAC1F,CAAC;IACD,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC3C,MAAM,GAAG,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;IACjC,GAAG,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAC9B,MAAM,SAAS,GAAG,GAAG,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IACxD,OAAO,cAAc,CAAC,SAAS,CAAC,CAAC;AACnC,CAAC"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Class label resolution: presets, lists, dicts, or auto-generated.
3
+ *
4
+ * Tasks call {@link resolveLabels} once at construction time to turn whatever
5
+ * the caller passed (preset name, array, dict, or `null`) into an ordered
6
+ * array of class names indexed by class id.
7
+ *
8
+ * In the browser there is no filesystem, so this module does not load labels
9
+ * from a path — fetch the file yourself and pass an array.
10
+ */
11
+ /**
12
+ * Anything accepted by {@link resolveLabels}.
13
+ *
14
+ * - `string[]` / `readonly string[]`: explicit names indexed by class id.
15
+ * - `Record<number, string>`: sparse mapping (gaps filled with `class_<id>`).
16
+ * - `string`: a preset name (e.g. `"coco"`).
17
+ * - `null` / `undefined`: auto-generate `class_0` ... `class_{numClasses-1}`.
18
+ */
19
+ export type LabelSpec = readonly string[] | Record<number, string> | string | null | undefined;
20
+ /** COCO 2017 80-class labels in canonical class-id order. */
21
+ export declare const COCO_CLASSES: readonly string[];
22
+ export interface ResolveLabelsOptions {
23
+ /**
24
+ * Expected number of classes.
25
+ *
26
+ * - When `spec` is `null`/`undefined`, this is required to auto-generate names.
27
+ * - When `spec` is provided, it validates that the resolved length matches.
28
+ */
29
+ readonly numClasses?: number;
30
+ }
31
+ /**
32
+ * Resolve a labels specification into an ordered array of class names.
33
+ *
34
+ * @throws {@link LabelMapError} if the spec is invalid, the preset is unknown,
35
+ * or the resolved length disagrees with `numClasses`.
36
+ */
37
+ export declare function resolveLabels(spec: LabelSpec, options?: ResolveLabelsOptions): readonly string[];
38
+ //# sourceMappingURL=labels.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"labels.d.ts","sourceRoot":"","sources":["../src/labels.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH;;;;;;;GAOG;AACH,MAAM,MAAM,SAAS,GACjB,SAAS,MAAM,EAAE,GACjB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACtB,MAAM,GACN,IAAI,GACJ,SAAS,CAAC;AAEd,6DAA6D;AAC7D,eAAO,MAAM,YAAY,EAAE,SAAS,MAAM,EAaxC,CAAC;AAMH,MAAM,WAAW,oBAAoB;IACnC;;;;;OAKG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,SAAS,EACf,OAAO,GAAE,oBAAyB,GACjC,SAAS,MAAM,EAAE,CAQnB"}
package/dist/labels.js ADDED
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Class label resolution: presets, lists, dicts, or auto-generated.
3
+ *
4
+ * Tasks call {@link resolveLabels} once at construction time to turn whatever
5
+ * the caller passed (preset name, array, dict, or `null`) into an ordered
6
+ * array of class names indexed by class id.
7
+ *
8
+ * In the browser there is no filesystem, so this module does not load labels
9
+ * from a path — fetch the file yourself and pass an array.
10
+ */
11
+ import { LabelMapError } from "./core/exceptions.js";
12
+ /** COCO 2017 80-class labels in canonical class-id order. */
13
+ export const COCO_CLASSES = Object.freeze([
14
+ "person", "bicycle", "car", "motorcycle", "airplane", "bus", "train", "truck",
15
+ "boat", "traffic light", "fire hydrant", "stop sign", "parking meter", "bench",
16
+ "bird", "cat", "dog", "horse", "sheep", "cow", "elephant", "bear", "zebra",
17
+ "giraffe", "backpack", "umbrella", "handbag", "tie", "suitcase", "frisbee",
18
+ "skis", "snowboard", "sports ball", "kite", "baseball bat", "baseball glove",
19
+ "skateboard", "surfboard", "tennis racket", "bottle", "wine glass", "cup",
20
+ "fork", "knife", "spoon", "bowl", "banana", "apple", "sandwich", "orange",
21
+ "broccoli", "carrot", "hot dog", "pizza", "donut", "cake", "chair", "couch",
22
+ "potted plant", "bed", "dining table", "toilet", "tv", "laptop", "mouse",
23
+ "remote", "keyboard", "cell phone", "microwave", "oven", "toaster", "sink",
24
+ "refrigerator", "book", "clock", "vase", "scissors", "teddy bear", "hair drier",
25
+ "toothbrush",
26
+ ]);
27
+ const PRESETS = {
28
+ coco: COCO_CLASSES,
29
+ };
30
+ /**
31
+ * Resolve a labels specification into an ordered array of class names.
32
+ *
33
+ * @throws {@link LabelMapError} if the spec is invalid, the preset is unknown,
34
+ * or the resolved length disagrees with `numClasses`.
35
+ */
36
+ export function resolveLabels(spec, options = {}) {
37
+ const labels = resolve(spec, options.numClasses);
38
+ if (options.numClasses !== undefined && labels.length !== options.numClasses) {
39
+ throw new LabelMapError(`Resolved ${labels.length} labels but the model has ${options.numClasses} classes.`);
40
+ }
41
+ return labels;
42
+ }
43
+ function resolve(spec, numClasses) {
44
+ if (spec === null || spec === undefined) {
45
+ if (numClasses === undefined) {
46
+ throw new LabelMapError("Cannot auto-generate labels without numClasses. Pass an explicit labels spec or numClasses.");
47
+ }
48
+ return Array.from({ length: numClasses }, (_, i) => `class_${i}`);
49
+ }
50
+ if (Array.isArray(spec)) {
51
+ return [...spec];
52
+ }
53
+ if (typeof spec === "string") {
54
+ const preset = PRESETS[spec];
55
+ if (preset !== undefined) {
56
+ return preset;
57
+ }
58
+ throw new LabelMapError(`Unknown labels preset: ${JSON.stringify(spec)}. Known presets: ${Object.keys(PRESETS).join(", ")}.`);
59
+ }
60
+ if (typeof spec === "object") {
61
+ const map = spec;
62
+ const ids = Object.keys(map).map((k) => Number(k));
63
+ if (ids.length === 0) {
64
+ return [];
65
+ }
66
+ const maxId = Math.max(...ids);
67
+ return Array.from({ length: maxId + 1 }, (_, i) => map[i] ?? `class_${i}`);
68
+ }
69
+ throw new LabelMapError(`Unsupported labels spec type: ${typeof spec}.`);
70
+ }
71
+ //# sourceMappingURL=labels.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"labels.js","sourceRoot":"","sources":["../src/labels.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAiBrD,6DAA6D;AAC7D,MAAM,CAAC,MAAM,YAAY,GAAsB,MAAM,CAAC,MAAM,CAAC;IAC3D,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO;IAC7E,MAAM,EAAE,eAAe,EAAE,cAAc,EAAE,WAAW,EAAE,eAAe,EAAE,OAAO;IAC9E,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO;IAC1E,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS;IAC1E,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,EAAE,cAAc,EAAE,gBAAgB;IAC5E,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,QAAQ,EAAE,YAAY,EAAE,KAAK;IACzE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ;IACzE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;IAC3E,cAAc,EAAE,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO;IACxE,QAAQ,EAAE,UAAU,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IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,MAAM,IAAI,aAAa,CACrB,0BAA0B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,oBAAoB,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CACrG,CAAC;IACJ,CAAC;IAED,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,MAAM,GAAG,GAAG,IAA8B,CAAC;QAC3C,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QACnD,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACrB,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC;QAC/B,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC,EAAE,CAAC,CAAC;IAC7E,CAAC;IAED,MAAM,IAAI,aAAa,CAAC,iCAAiC,OAAO,IAAI,GAAG,CAAC,CAAC;AAC3E,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Classification head postprocessing — softmax + top-k.
3
+ */
4
+ /** Apply numerically-stable softmax to a 1-D vector of logits. */
5
+ export declare function softmax(logits: Float32Array | readonly number[]): Float32Array;
6
+ export interface TopKResult {
7
+ readonly indices: Int32Array;
8
+ readonly values: Float32Array;
9
+ }
10
+ /**
11
+ * Return the top-k entries of a 1-D probability vector, sorted descending.
12
+ *
13
+ * @param k Number of entries to return; `null` returns all entries.
14
+ */
15
+ export declare function topK(probabilities: Float32Array, k: number | null): TopKResult;
16
+ //# sourceMappingURL=classification.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"classification.d.ts","sourceRoot":"","sources":["../../src/postprocess/classification.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,kEAAkE;AAClE,wBAAgB,OAAO,CACrB,MAAM,EAAE,YAAY,GAAG,SAAS,MAAM,EAAE,GACvC,YAAY,CAkBd;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;CAC/B;AAED;;;;GAIG;AACH,wBAAgB,IAAI,CAClB,aAAa,EAAE,YAAY,EAC3B,CAAC,EAAE,MAAM,GAAG,IAAI,GACf,UAAU,CAgBZ"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Classification head postprocessing — softmax + top-k.
3
+ */
4
+ /** Apply numerically-stable softmax to a 1-D vector of logits. */
5
+ export function softmax(logits) {
6
+ const n = logits.length;
7
+ const out = new Float32Array(n);
8
+ let max = -Infinity;
9
+ for (let i = 0; i < n; i++) {
10
+ const v = logits[i];
11
+ if (v > max)
12
+ max = v;
13
+ }
14
+ let sum = 0;
15
+ for (let i = 0; i < n; i++) {
16
+ const e = Math.exp(logits[i] - max);
17
+ out[i] = e;
18
+ sum += e;
19
+ }
20
+ for (let i = 0; i < n; i++) {
21
+ out[i] = out[i] / sum;
22
+ }
23
+ return out;
24
+ }
25
+ /**
26
+ * Return the top-k entries of a 1-D probability vector, sorted descending.
27
+ *
28
+ * @param k Number of entries to return; `null` returns all entries.
29
+ */
30
+ export function topK(probabilities, k) {
31
+ const n = probabilities.length;
32
+ const kEff = k === null ? n : Math.min(Math.max(0, k), n);
33
+ const idx = new Array(n);
34
+ for (let i = 0; i < n; i++)
35
+ idx[i] = i;
36
+ idx.sort((a, b) => probabilities[b] - probabilities[a]);
37
+ const indices = new Int32Array(kEff);
38
+ const values = new Float32Array(kEff);
39
+ for (let i = 0; i < kEff; i++) {
40
+ const j = idx[i];
41
+ indices[i] = j;
42
+ values[i] = probabilities[j];
43
+ }
44
+ return { indices, values };
45
+ }
46
+ //# sourceMappingURL=classification.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"classification.js","sourceRoot":"","sources":["../../src/postprocess/classification.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,kEAAkE;AAClE,MAAM,UAAU,OAAO,CACrB,MAAwC;IAExC,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC;IACxB,MAAM,GAAG,GAAG,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC;IAChC,IAAI,GAAG,GAAG,CAAC,QAAQ,CAAC;IACpB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3B,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,CAAW,CAAC;QAC9B,IAAI,CAAC,GAAG,GAAG;YAAE,GAAG,GAAG,CAAC,CAAC;IACvB,CAAC;IACD,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3B,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAE,MAAM,CAAC,CAAC,CAAY,GAAG,GAAG,CAAC,CAAC;QAChD,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QACX,GAAG,IAAI,CAAC,CAAC;IACX,CAAC;IACD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3B,GAAG,CAAC,CAAC,CAAC,GAAI,GAAG,CAAC,CAAC,CAAY,GAAG,GAAG,CAAC;IACpC,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAOD;;;;GAIG;AACH,MAAM,UAAU,IAAI,CAClB,aAA2B,EAC3B,CAAgB;IAEhB,MAAM,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC;IAC/B,MAAM,IAAI,GAAG,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAE1D,MAAM,GAAG,GAAG,IAAI,KAAK,CAAS,CAAC,CAAC,CAAC;IACjC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;QAAE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACvC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAE,aAAa,CAAC,CAAC,CAAY,GAAI,aAAa,CAAC,CAAC,CAAY,CAAC,CAAC;IAEhF,MAAM,OAAO,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;IACrC,MAAM,MAAM,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC;IACtC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9B,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,CAAW,CAAC;QAC3B,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QACf,MAAM,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAW,CAAC;IACzC,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AAC7B,CAAC"}
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Detection head postprocessing: anchor-free YOLO decoding + non-maximum suppression.
3
+ *
4
+ * The shared {@link decodeYoloAnchors} helper does the per-anchor work that
5
+ * is identical for plain detection and segmentation (transpose, xywh→xyxy,
6
+ * letterbox unmap, per-class NMS, sort & cap). {@link decodeYolo} is a thin
7
+ * wrapper around it; the segmentation module ({@link ./segmentation.js})
8
+ * calls the helper directly so it can also recover the per-anchor mask
9
+ * coefficients.
10
+ *
11
+ * Works for any YOLO export with the post-v8 anchor-free head:
12
+ * **YOLOv8 / v9 / v10 / v11 / v12** detect heads, all of which share the
13
+ * `[1, 4 + nc, N]` output layout.
14
+ */
15
+ import { BoundingBox } from "../types.js";
16
+ /**
17
+ * Greedy non-maximum suppression on axis-aligned bounding boxes.
18
+ *
19
+ * Mirrors `torchvision.ops.nms` (keeps boxes with the highest score, drops
20
+ * any subsequent box whose IoU exceeds the threshold).
21
+ *
22
+ * @param boxes Flat array of length `4 * N` in xyxy order: `[x1,y1,x2,y2, ...]`.
23
+ * @param scores Detection score per box, length `N`.
24
+ * @param iouThreshold Boxes with IoU above this threshold relative to a kept box are suppressed.
25
+ * @returns Indices of kept boxes, in descending score order.
26
+ */
27
+ export declare function nms(boxes: Float32Array, scores: Float32Array, iouThreshold: number): Int32Array;
28
+ /**
29
+ * Per-class NMS — boxes are suppressed only by other boxes of the same class.
30
+ *
31
+ * Mirrors `torchvision.ops.batched_nms`.
32
+ *
33
+ * @param boxes Flat array of length `4 * N` in xyxy order.
34
+ * @param scores Detection score per box, length `N`.
35
+ * @param idxs Class index per box, length `N`. Boxes with different `idxs`
36
+ * never suppress each other.
37
+ * @param iouThreshold IoU threshold for suppression within a class.
38
+ */
39
+ export declare function batchedNms(boxes: Float32Array, scores: Float32Array, idxs: Int32Array, iouThreshold: number): Int32Array;
40
+ export interface DecodeYoloAnchorsOptions {
41
+ /** Number of class-score channels following the 4 box channels. */
42
+ readonly numClasses: number;
43
+ readonly originalWidth: number;
44
+ readonly originalHeight: number;
45
+ readonly padLeft: number;
46
+ readonly padTop: number;
47
+ readonly scale: number;
48
+ readonly confThreshold: number;
49
+ readonly iouThreshold: number;
50
+ readonly maxDetections: number;
51
+ }
52
+ export interface DecodedAnchors {
53
+ /** Indices into the original `numAnchors` axis, in descending confidence order. */
54
+ readonly anchorIndices: Int32Array;
55
+ /** `[k, 4]` boxes in original-image pixel coords, flat row-major xyxy. */
56
+ readonly boxesXyxy: Float32Array;
57
+ /** Predicted class id per survivor. */
58
+ readonly classIds: Int32Array;
59
+ /** Confidence per survivor. */
60
+ readonly confidences: Float32Array;
61
+ }
62
+ /**
63
+ * Shared YOLO per-anchor decode used by both detection and segmentation
64
+ * (v8 / v9 / v10 / v11 / v12).
65
+ *
66
+ * Only the first `4 + numClasses` channels are read; later channels (e.g.
67
+ * mask coefficients) are ignored — callers can fetch them via the returned
68
+ * {@link DecodedAnchors.anchorIndices}.
69
+ *
70
+ * @param data Flat per-anchor output, length `channels * numAnchors`.
71
+ * @param dims Dims as reported by ORT, e.g. `[1, 84, 8400]` (det) or
72
+ * `[1, 116, 8400]` (seg). The leading batch dim must be 1.
73
+ */
74
+ export declare function decodeYoloAnchors(data: Float32Array, dims: readonly number[], options: DecodeYoloAnchorsOptions): DecodedAnchors;
75
+ export interface DecodeYoloOptions {
76
+ readonly originalWidth: number;
77
+ readonly originalHeight: number;
78
+ readonly padLeft: number;
79
+ readonly padTop: number;
80
+ readonly scale: number;
81
+ readonly confThreshold: number;
82
+ readonly iouThreshold: number;
83
+ readonly maxDetections: number;
84
+ }
85
+ export interface DecodedDetection {
86
+ readonly bbox: BoundingBox;
87
+ readonly classId: number;
88
+ readonly confidence: number;
89
+ }
90
+ /**
91
+ * Decode an anchor-free YOLO detection output into a list of detections.
92
+ *
93
+ * Works for **YOLOv8 / v9 / v10 / v11 / v12** detect heads.
94
+ *
95
+ * Expected raw shape: `[1, 4 + numClasses, N]`. `numClasses` is inferred
96
+ * from the channel count.
97
+ */
98
+ export declare function decodeYolo(output: Float32Array, outputDims: readonly number[], options: DecodeYoloOptions): DecodedDetection[];
99
+ /**
100
+ * @deprecated since 0.2.0 — use {@link decodeYolo}. Same behavior; the
101
+ * decoder covers v8/v9/v10/v11/v12 detect heads. Will be removed in 0.3.0.
102
+ */
103
+ export declare function decodeYoloV8(output: Float32Array, outputDims: readonly number[], options: DecodeYoloOptions): DecodedDetection[];
104
+ /**
105
+ * @deprecated since 0.2.0 — use {@link decodeYoloAnchors}. Will be removed in 0.3.0.
106
+ */
107
+ export declare function decodeYoloV8Anchors(data: Float32Array, dims: readonly number[], options: DecodeYoloAnchorsOptions): DecodedAnchors;
108
+ /** @deprecated since 0.2.0 — use {@link DecodeYoloAnchorsOptions}. */
109
+ export type DecodeYoloV8AnchorsOptions = DecodeYoloAnchorsOptions;
110
+ /** @deprecated since 0.2.0 — use {@link DecodeYoloOptions}. */
111
+ export type DecodeYoloV8Options = DecodeYoloOptions;
112
+ //# sourceMappingURL=detection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detection.d.ts","sourceRoot":"","sources":["../../src/postprocess/detection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C;;;;;;;;;;GAUG;AACH,wBAAgB,GAAG,CACjB,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,MAAM,GACnB,UAAU,CAsDZ;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,UAAU,EAChB,YAAY,EAAE,MAAM,GACnB,UAAU,CAgCZ;AAED,MAAM,WAAW,wBAAwB;IACvC,mEAAmE;IACnE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC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