@hackbuild/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.
package/dist/loaders.js CHANGED
@@ -14,7 +14,7 @@ async function toRaw(tjs, img) {
14
14
  const R = tjs.RawImage;
15
15
  return R?.read ? R.read(img) : img;
16
16
  }
17
- /** Normalize a depth pipeline result. predicted_depth keeps the raw range (as earlier builds did); depth is the 8 bit image (as earlier builds did). */
17
+ /** Normalize a depth pipeline result. predicted_depth keeps the raw range; depth is the 8 bit image. */
18
18
  export function depthFromOutput(out) {
19
19
  const pd = out.predicted_depth;
20
20
  if (pd && pd.data && pd.dims?.length >= 2) {
@@ -44,6 +44,7 @@ export function depthFromOutput(out) {
44
44
  data[i] = d.data[i * ch] / 255;
45
45
  return { width: d.width, height: d.height, data, range: [0, 255] };
46
46
  }
47
+ /** The transformers.js loader for depth records: a depth-estimation pipeline wrapped as a {@link DepthModel}. */
47
48
  export async function depthLoader(ctx) {
48
49
  const pipe = (await ctx.tjs.pipeline("depth-estimation", ctx.record.source.modelId, ctx.options));
49
50
  return {
@@ -51,6 +52,7 @@ export async function depthLoader(ctx) {
51
52
  dispose: () => pipe.dispose?.(),
52
53
  };
53
54
  }
55
+ /** The transformers.js loader for caption and question records: the VLM's processor and model wrapped as a {@link Vlm}. */
54
56
  export async function vlmLoader(ctx) {
55
57
  const id = ctx.record.source.modelId;
56
58
  const processor = (await cls(ctx.tjs, "AutoProcessor").from_pretrained(id));
package/dist/loop.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
- * A perception loop beside a render loop: one step at a time (the earlier scan bench's
3
- * busy guard), each step started no sooner than `interval(lastLatency)`
4
- * after the previous one began (an earlier scene app detection cadence, the earlier chat build's fixed
5
- * periods), stopped by `stop()` or an abort signal. The scheduler is
2
+ * A perception loop beside a render loop: one step at a time (a busy
3
+ * guard), each step started no sooner than `interval(lastLatency)`
4
+ * after the previous one began (an adaptive cadence or a fixed
5
+ * period), stopped by `stop()` or an abort signal. The scheduler is
6
6
  * injectable so tests run without timers.
7
7
  */
8
8
  export interface LoopOptions<T> {
@@ -18,6 +18,7 @@ export interface LoopOptions<T> {
18
18
  /** Called on each frame that found the previous step still running. */
19
19
  onBusy?: () => void;
20
20
  }
21
+ /** A running loop: `stop`, whether it runs or is busy, the last step's latency and the step count. */
21
22
  export interface Loop {
22
23
  stop(): void;
23
24
  readonly running: boolean;
@@ -25,13 +26,15 @@ export interface Loop {
25
26
  readonly lastLatencyMs: number;
26
27
  readonly steps: number;
27
28
  }
29
+ /** Run a perception step beside a render loop, one at a time, each started no sooner than `interval(lastLatency)` after the previous one began. */
28
30
  export declare function perceptionLoop<T>(o: LoopOptions<T>): Loop;
31
+ /** Options for {@link readbackLoop}: the async read, the frame consumer, a rate cap (10 Hz), and an abort signal. */
29
32
  export interface ReadbackOptions<T> {
30
33
  /** An async readback, e.g. three.js readRenderTargetPixelsAsync or a canvas createImageBitmap. */
31
34
  read: () => Promise<T>;
32
35
  /** Consumer of each frame; a slow consumer holds the loop (it runs inside the busy window). */
33
36
  onFrame: (frame: T) => void | Promise<void>;
34
- /** Rate cap. Default 10 Hz (as earlier builds did). */
37
+ /** Rate cap. Default 10 Hz. */
35
38
  maxHz?: number;
36
39
  onError?: (e: unknown) => void;
37
40
  now?: () => number;
@@ -46,7 +49,7 @@ export interface ReadbackOptions<T> {
46
49
  export declare function readbackLoop<T>(o: ReadbackOptions<T>): Loop & {
47
50
  readonly skipped: number;
48
51
  };
49
- /** A small LRU of results by key (an earlier relief bench keeps the depth map with the design so it never reruns). */
52
+ /** A small LRU of results by key, so a depth map is computed once per image. */
50
53
  export declare class ResultCache<T> {
51
54
  private readonly max;
52
55
  private readonly m;
@@ -56,13 +59,13 @@ export declare class ResultCache<T> {
56
59
  getOr(key: string, make: () => Promise<T>): Promise<T>;
57
60
  get size(): number;
58
61
  }
59
- /** A depth map as an 8 bit grey RGBA buffer, for a canvas or a PNG (an earlier relief bench stores depth as a PNG data URL). */
62
+ /** A depth map as an 8 bit grey RGBA buffer, for a canvas or a PNG (store it as a PNG data URL to keep it with a design). */
60
63
  export declare function depthToRgba(d: {
61
64
  width: number;
62
65
  height: number;
63
66
  data: Float32Array;
64
67
  }): Uint8ClampedArray;
65
- /** Scale so the longest side is at most maxPx (as earlier builds did). */
68
+ /** Scale so the longest side is at most maxPx. */
66
69
  export declare function fitSize(w: number, h: number, maxPx?: number): {
67
70
  width: number;
68
71
  height: number;
package/dist/loop.js CHANGED
@@ -1,10 +1,11 @@
1
1
  /**
2
- * A perception loop beside a render loop: one step at a time (the earlier scan bench's
3
- * busy guard), each step started no sooner than `interval(lastLatency)`
4
- * after the previous one began (an earlier scene app detection cadence, the earlier chat build's fixed
5
- * periods), stopped by `stop()` or an abort signal. The scheduler is
2
+ * A perception loop beside a render loop: one step at a time (a busy
3
+ * guard), each step started no sooner than `interval(lastLatency)`
4
+ * after the previous one began (an adaptive cadence or a fixed
5
+ * period), stopped by `stop()` or an abort signal. The scheduler is
6
6
  * injectable so tests run without timers.
7
7
  */
8
+ /** Run a perception step beside a render loop, one at a time, each started no sooner than `interval(lastLatency)` after the previous one began. */
8
9
  export function perceptionLoop(o) {
9
10
  const now = o.now ?? (() => (globalThis.performance ? performance.now() : Date.now()));
10
11
  const g = globalThis;
@@ -103,7 +104,7 @@ export function readbackLoop(o) {
103
104
  },
104
105
  };
105
106
  }
106
- /** A small LRU of results by key (an earlier relief bench keeps the depth map with the design so it never reruns). */
107
+ /** A small LRU of results by key, so a depth map is computed once per image. */
107
108
  export class ResultCache {
108
109
  max;
109
110
  m = new Map();
@@ -136,7 +137,7 @@ export class ResultCache {
136
137
  return this.m.size;
137
138
  }
138
139
  }
139
- /** A depth map as an 8 bit grey RGBA buffer, for a canvas or a PNG (an earlier relief bench stores depth as a PNG data URL). */
140
+ /** A depth map as an 8 bit grey RGBA buffer, for a canvas or a PNG (store it as a PNG data URL to keep it with a design). */
140
141
  export function depthToRgba(d) {
141
142
  const out = new Uint8ClampedArray(d.width * d.height * 4);
142
143
  for (let i = 0; i < d.width * d.height; i++) {
@@ -146,7 +147,7 @@ export function depthToRgba(d) {
146
147
  }
147
148
  return out;
148
149
  }
149
- /** Scale so the longest side is at most maxPx (as earlier builds did). */
150
+ /** Scale so the longest side is at most maxPx. */
150
151
  export function fitSize(w, h, maxPx = 1024) {
151
152
  const s = Math.min(1, maxPx / Math.max(w, h));
152
153
  return { width: Math.max(1, Math.round(w * s)), height: Math.max(1, Math.round(h * s)), scale: s };
package/dist/masks.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Mask operations and mask export, as plain functions on `Mask` (0 to 255
3
- * per pixel, 128 and up counts as inside). The operations are the earlier
4
- * mask studio's set (union, subtract, invert, smooth, expand, shrink,
3
+ * per pixel, 128 and up counts as inside). The operations are a mask
4
+ * editor's set (union, subtract, invert, smooth, expand, shrink,
5
5
  * keep the largest piece); dilate and erode use an exact distance
6
6
  * transform, so a radius costs the same at any size and the image border
7
7
  * is not eaten. Exports: grey PNG, PNG with the mask as alpha, an SVG
@@ -14,16 +14,19 @@ export declare function emptyMask(width: number, height: number): Mask;
14
14
  export declare function maskArea(m: Mask): number;
15
15
  /** Every value to 0 or 255 at `t`. */
16
16
  export declare function maskThreshold(m: Mask, t?: number): Mask;
17
+ /** Pixels inside either mask, the larger value of each. Throws when the sizes differ. */
17
18
  export declare function maskUnion(a: Mask, b: Mask): Mask;
19
+ /** Pixels inside both masks, the smaller value of each. Throws when the sizes differ. */
18
20
  export declare function maskIntersect(a: Mask, b: Mask): Mask;
19
- /** `a` with `b` taken out (shift with a selection tool in the earlier mask studio). */
21
+ /** `a` with `b` taken out (shift with a selection tool in a mask editor). */
20
22
  export declare function maskSubtract(a: Mask, b: Mask): Mask;
23
+ /** The mask with inside and outside swapped, 255 minus each value. */
21
24
  export declare function maskInvert(m: Mask): Mask;
22
25
  /** Grow by a disc of radius `r` pixels (expand). */
23
26
  export declare function maskDilate(m: Mask, r: number): Mask;
24
27
  /** Shrink by a disc of radius `r` pixels; the image border does not count as outside. */
25
28
  export declare function maskErode(m: Mask, r: number): Mask;
26
- /** Soft edges: a gaussian of radius `r` with sigma r / 2 (the earlier mask studio's smooth, before its rethreshold), edges clamped. */
29
+ /** Soft edges: a gaussian of radius `r` with sigma r / 2 (a smooth without a rethreshold), edges clamped. */
27
30
  export declare function maskFeather(m: Mask, r: number): Mask;
28
31
  /** Keep only the largest connected piece (8 connected by default). */
29
32
  export declare function maskLargestComponent(m: Mask, connectivity?: 4 | 8): Mask;
@@ -63,5 +66,7 @@ export interface MaskRle {
63
66
  size: [height: number, width: number];
64
67
  counts: number[];
65
68
  }
69
+ /** The mask as COCO style uncompressed run length, column major, 128 and up inside. */
66
70
  export declare function maskToRle(m: Mask): MaskRle;
71
+ /** A mask from COCO style run length, inside 255. Throws when the counts do not cover the image. */
67
72
  export declare function maskFromRle(r: MaskRle): Mask;
package/dist/masks.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Mask operations and mask export, as plain functions on `Mask` (0 to 255
3
- * per pixel, 128 and up counts as inside). The operations are the earlier
4
- * mask studio's set (union, subtract, invert, smooth, expand, shrink,
3
+ * per pixel, 128 and up counts as inside). The operations are a mask
4
+ * editor's set (union, subtract, invert, smooth, expand, shrink,
5
5
  * keep the largest piece); dilate and erode use an exact distance
6
6
  * transform, so a radius costs the same at any size and the image border
7
7
  * is not eaten. Exports: grey PNG, PNG with the mask as alpha, an SVG
@@ -29,19 +29,22 @@ export function maskArea(m) {
29
29
  export function maskThreshold(m, t = ON) {
30
30
  return make(m, m.data.map((v) => (v >= t ? 255 : 0)));
31
31
  }
32
+ /** Pixels inside either mask, the larger value of each. Throws when the sizes differ. */
32
33
  export function maskUnion(a, b) {
33
34
  same("maskUnion", a, b);
34
35
  return make(a, a.data.map((v, i) => Math.max(v, b.data[i])));
35
36
  }
37
+ /** Pixels inside both masks, the smaller value of each. Throws when the sizes differ. */
36
38
  export function maskIntersect(a, b) {
37
39
  same("maskIntersect", a, b);
38
40
  return make(a, a.data.map((v, i) => Math.min(v, b.data[i])));
39
41
  }
40
- /** `a` with `b` taken out (shift with a selection tool in the earlier mask studio). */
42
+ /** `a` with `b` taken out (shift with a selection tool in a mask editor). */
41
43
  export function maskSubtract(a, b) {
42
44
  same("maskSubtract", a, b);
43
45
  return make(a, a.data.map((v, i) => Math.min(v, 255 - b.data[i])));
44
46
  }
47
+ /** The mask with inside and outside swapped, 255 minus each value. */
45
48
  export function maskInvert(m) {
46
49
  return make(m, m.data.map((v) => 255 - v));
47
50
  }
@@ -103,7 +106,7 @@ export function maskErode(m, r) {
103
106
  const d = distance2((i) => m.data[i] < ON, m.width, m.height);
104
107
  return make(m, Uint8Array.from(d, (v) => (v > r * r ? 255 : 0)));
105
108
  }
106
- /** Soft edges: a gaussian of radius `r` with sigma r / 2 (the earlier mask studio's smooth, before its rethreshold), edges clamped. */
109
+ /** Soft edges: a gaussian of radius `r` with sigma r / 2 (a smooth without a rethreshold), edges clamped. */
107
110
  export function maskFeather(m, r) {
108
111
  if (r <= 0)
109
112
  return make(m, m.data.slice());
@@ -364,6 +367,7 @@ export function maskToSvg(m, o = {}) {
364
367
  .join("");
365
368
  return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${m.width} ${m.height}" width="${m.width}" height="${m.height}"><path d="${d}" fill="${o.fill ?? "#000"}" fill-rule="evenodd"/></svg>`;
366
369
  }
370
+ /** The mask as COCO style uncompressed run length, column major, 128 and up inside. */
367
371
  export function maskToRle(m) {
368
372
  const { width: w, height: h } = m;
369
373
  const counts = [];
@@ -382,6 +386,7 @@ export function maskToRle(m) {
382
386
  counts.push(run);
383
387
  return { size: [h, w], counts };
384
388
  }
389
+ /** A mask from COCO style run length, inside 255. Throws when the counts do not cover the image. */
385
390
  export function maskFromRle(r) {
386
391
  const [h, w] = r.size;
387
392
  const data = new Uint8Array(w * h);
@@ -2,12 +2,13 @@
2
2
  * A MediaPipe tasks-vision provider for the models hub. One wasm fileset
3
3
  * per page; one task per record, created with the GPU delegate on a
4
4
  * "webgl" rung and the CPU delegate on a "wasm" rung, so a failed GPU
5
- * delegate falls to the CPU one (FaceSwap and an earlier scene app had no fallback).
5
+ * delegate falls to the CPU one.
6
6
  * Results are turned into the package's Detector, Segmenter and
7
7
  * Landmarker shapes.
8
8
  */
9
9
  import type { Factory } from "@hackbuild/models";
10
10
  import type { WeightStore } from "@hackbuild/weights";
11
+ /** The pinned @mediapipe/tasks-vision version, 1.2.3. */
11
12
  export declare const TASKS_VISION = "1.2.3";
12
13
  interface TaskClass {
13
14
  createFromOptions(fileset: unknown, opts: Record<string, unknown>): Promise<Record<string, (...a: unknown[]) => unknown>>;
@@ -24,14 +25,19 @@ export interface TasksVision {
24
25
  PoseLandmarker?: TaskClass;
25
26
  GestureRecognizer?: TaskClass;
26
27
  }
28
+ /** The URL @mediapipe/tasks-vision is imported from, on jsDelivr. */
27
29
  export declare function tasksVisionUrls(version?: string): string[];
30
+ /** The directory of the tasks-vision wasm fileset, on jsDelivr. */
28
31
  export declare function tasksVisionWasm(version?: string): string;
32
+ /** A loader that imports the pinned @mediapipe/tasks-vision at run time; pass it as `runtime` to {@link mediapipeProvider}. */
29
33
  export declare const loadTasksVision: (version?: string) => () => Promise<TasksVision>;
34
+ /** Options for {@link mediapipeProvider}: the runtime loader, the wasm fileset directory, and a weight store to read model files through. */
30
35
  export interface MediapipeProviderOptions {
31
36
  runtime: () => Promise<TasksVision>;
32
37
  wasmBase?: string;
33
38
  /** Read model files through the weight store (resume, sha-256, licence line) and pass them as buffers. */
34
39
  store?: WeightStore;
35
40
  }
41
+ /** The MediaPipe tasks-vision provider for the models hub: one task per record, the GPU delegate on a webgl rung and the CPU delegate on a wasm rung. */
36
42
  export declare function mediapipeProvider(opts: MediapipeProviderOptions): Factory;
37
43
  export {};
package/dist/mediapipe.js CHANGED
@@ -2,18 +2,22 @@
2
2
  * A MediaPipe tasks-vision provider for the models hub. One wasm fileset
3
3
  * per page; one task per record, created with the GPU delegate on a
4
4
  * "webgl" rung and the CPU delegate on a "wasm" rung, so a failed GPU
5
- * delegate falls to the CPU one (FaceSwap and an earlier scene app had no fallback).
5
+ * delegate falls to the CPU one.
6
6
  * Results are turned into the package's Detector, Segmenter and
7
7
  * Landmarker shapes.
8
8
  */
9
9
  import { importEsm } from "@hackbuild/ai-env";
10
+ /** The pinned @mediapipe/tasks-vision version, 1.2.3. */
10
11
  export const TASKS_VISION = "1.2.3";
12
+ /** The URL @mediapipe/tasks-vision is imported from, on jsDelivr. */
11
13
  export function tasksVisionUrls(version = TASKS_VISION) {
12
14
  return [`https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@${version}/vision_bundle.mjs`];
13
15
  }
16
+ /** The directory of the tasks-vision wasm fileset, on jsDelivr. */
14
17
  export function tasksVisionWasm(version = TASKS_VISION) {
15
18
  return `https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@${version}/wasm`;
16
19
  }
20
+ /** A loader that imports the pinned @mediapipe/tasks-vision at run time; pass it as `runtime` to {@link mediapipeProvider}. */
17
21
  export const loadTasksVision = (version = TASKS_VISION) => () => importEsm(tasksVisionUrls(version));
18
22
  const CLASS = {
19
23
  detect: "ObjectDetector",
@@ -80,6 +84,7 @@ function landmarker(t, kind, video, source) {
80
84
  dispose: () => call(t, "close"),
81
85
  };
82
86
  }
87
+ /** The MediaPipe tasks-vision provider for the models hub: one task per record, the GPU delegate on a webgl rung and the CPU delegate on a wasm rung. */
83
88
  export function mediapipeProvider(opts) {
84
89
  let fileset = null;
85
90
  return async ({ record, rung, signal }) => {
package/dist/records.d.ts CHANGED
@@ -1,15 +1,21 @@
1
1
  /**
2
2
  * Vision records for the models hub. Licences are the model cards' as of
3
- * 2026-11-22; sizes are inferred from the builds and parameter counts.
3
+ * 2026-11-22; sizes are inferred from the builds and parameter counts, except where
4
+ * a row says vendor: those sum the hub listing's files (no download), in MiB.
4
5
  * YOLO weights are AGPL-3.0 (Ultralytics): they are never registered by
5
- * default, and `yoloRecord` builds a record only for a URL the app
6
- * supplies.
6
+ * default. YOLOv8n has no public hub repo, so `yoloRecord` builds a record
7
+ * only for a URL the app supplies; YOLOv10 n, s and m, FastSAM and the face
8
+ * swap set sit in PICKER_RECORDS.
7
9
  */
8
10
  import type { ModelRecord, Rung } from "@hackbuild/models";
11
+ /** The MediaPipe model storage base URL the MediaPipe records load from. */
9
12
  export declare const MP_MODELS = "https://storage.googleapis.com/mediapipe-models/";
10
13
  /** MediaPipe ladder: GPU delegate (webgl), then the CPU delegate (wasm). */
11
14
  export declare const mediapipeLadder: () => Rung[];
15
+ /** The vision records registered by `attachVision`: Depth Anything V2 small, MediaPipe detection, segmentation and landmarks, SlimSAM, SmolVLM 256M and LFM2-VL 450M. */
12
16
  export declare const VISION_RECORDS: ModelRecord[];
17
+ /** Records listed for pickers and never registered by default: larger alternates, and records under licences that limit use (YOLOv10, FastSAM, the face swap set). */
18
+ export declare const PICKER_RECORDS: ModelRecord[];
13
19
  /** A face landmark fallback record over face-api.js tiny nets (code MIT; weights MIT from @vladmandic/face-api). */
14
20
  export declare function faceApiRecord(baseUrl: string): ModelRecord;
15
21
  /** YOLOv8n exported to ONNX (640 input, [1, 84, 8400] output). External: the app supplies the URL and accepts the weight licence. */
package/dist/records.js CHANGED
@@ -1,17 +1,23 @@
1
1
  /**
2
2
  * Vision records for the models hub. Licences are the model cards' as of
3
- * 2026-11-22; sizes are inferred from the builds and parameter counts.
3
+ * 2026-11-22; sizes are inferred from the builds and parameter counts, except where
4
+ * a row says vendor: those sum the hub listing's files (no download), in MiB.
4
5
  * YOLO weights are AGPL-3.0 (Ultralytics): they are never registered by
5
- * default, and `yoloRecord` builds a record only for a URL the app
6
- * supplies.
6
+ * default. YOLOv8n has no public hub repo, so `yoloRecord` builds a record
7
+ * only for a URL the app supplies; YOLOv10 n, s and m, FastSAM and the face
8
+ * swap set sit in PICKER_RECORDS.
7
9
  */
8
10
  import { LADDERS, tjsLadder } from "@hackbuild/devices";
11
+ /** The MediaPipe model storage base URL the MediaPipe records load from. */
9
12
  export const MP_MODELS = "https://storage.googleapis.com/mediapipe-models/";
10
13
  /** MediaPipe ladder: GPU delegate (webgl), then the CPU delegate (wasm). */
11
14
  export const mediapipeLadder = () => [{ device: "webgl" }, { device: "wasm" }];
12
- const mp = (id, provides, path, sizeMB, label) => ({
15
+ const mp = (id, provides, path, sizeMB, label, verdict = "light, on the gpu", group = "start here") => ({
13
16
  id,
14
17
  label,
18
+ group,
19
+ speed: "instant",
20
+ verdict,
15
21
  provides: [provides],
16
22
  provider: "mediapipe",
17
23
  source: { url: MP_MODELS + path },
@@ -23,10 +29,14 @@ const mp = (id, provides, path, sizeMB, label) => ({
23
29
  place: "main",
24
30
  runtime: "@mediapipe/tasks-vision@1.2.3",
25
31
  });
32
+ /** The vision records registered by `attachVision`: Depth Anything V2 small, MediaPipe detection, segmentation and landmarks, SlimSAM, SmolVLM 256M and LFM2-VL 450M. */
26
33
  export const VISION_RECORDS = [
27
34
  {
28
35
  id: "depth-anything-v2-small",
29
36
  label: "depth anything v2 small",
37
+ speed: "fast",
38
+ verdict: "good edges",
39
+ group: "start here",
30
40
  provides: ["depth"],
31
41
  provider: "tjs",
32
42
  source: { modelId: "onnx-community/depth-anything-v2-small" },
@@ -37,9 +47,9 @@ export const VISION_RECORDS = [
37
47
  commercial: true,
38
48
  place: "cpu-worker",
39
49
  runtime: "@huggingface/transformers@4.3.2",
40
- notes: ["earlier builds: fp16 on webgpu, fp32 on the same device after a failure"],
50
+ notes: ["fp16 on webgpu, fp32 on the same device after a failure"],
41
51
  },
42
- mp("efficientdet-lite0", "detect", "object_detector/efficientdet_lite0/float16/1/efficientdet_lite0.tflite", 7, "mediapipe efficientdet lite0 (coco, 80 classes)"),
52
+ mp("efficientdet-lite0", "detect", "object_detector/efficientdet_lite0/float16/1/efficientdet_lite0.tflite", 7, "mediapipe efficientdet lite0 (coco, 80 classes)", "light, 80 things"),
43
53
  mp("selfie-segmenter", "segment.person", "image_segmenter/selfie_segmenter/float16/latest/selfie_segmenter.tflite", 1, "mediapipe selfie segmenter"),
44
54
  mp("face-landmarker", "landmarks.face", "face_landmarker/face_landmarker/float16/1/face_landmarker.task", 4, "mediapipe face landmarker with blendshapes"),
45
55
  mp("hand-landmarker", "landmarks.hand", "hand_landmarker/hand_landmarker/float16/1/hand_landmarker.task", 8, "mediapipe hand landmarker"),
@@ -54,21 +64,28 @@ export const VISION_RECORDS = [
54
64
  {
55
65
  id: "slimsam-77-uniform",
56
66
  label: "slimsam 77 uniform (point prompts)",
67
+ speed: "fast",
68
+ verdict: "click to cut",
69
+ group: "start here",
57
70
  provides: ["segment"],
58
71
  provider: "tjs",
59
72
  source: { modelId: "Xenova/slimsam-77-uniform" },
60
- sizeMB: 40,
61
- sizeSource: "inferred",
73
+ // fp32 vision encoder 23.3 plus prompt decoder 16.6 MB in the hub listing, 38 MiB; quantized 13.8 MB (vendor, 2026-11-25)
74
+ sizeMB: 38,
75
+ sizeSource: "vendor",
62
76
  ladder: tjsLadder({ webgpu: ["fp16", "fp32"], wasm: ["fp32"] }),
63
77
  licence: "Apache-2.0",
64
78
  commercial: true,
65
79
  place: "cpu-worker",
66
80
  runtime: "@huggingface/transformers@4.3.2",
67
- notes: ["earlier builds: one image embedding, then any number of point prompts"],
81
+ notes: ["one image embedding, then any number of point prompts"],
68
82
  },
69
83
  {
70
84
  id: "smolvlm-256m-instruct",
71
85
  label: "smolvlm 256m",
86
+ speed: "fast",
87
+ verdict: "fastest, short answers",
88
+ group: "start here",
72
89
  provides: ["vision.caption", "vision.ask"],
73
90
  provider: "tjs",
74
91
  source: { modelId: "HuggingFaceTB/SmolVLM-256M-Instruct" },
@@ -84,6 +101,9 @@ export const VISION_RECORDS = [
84
101
  {
85
102
  id: "lfm2-vl-450m",
86
103
  label: "lfm2-vl 450m",
104
+ speed: "fast",
105
+ verdict: "faster, sharper",
106
+ group: "tiny",
87
107
  provides: ["vision.caption", "vision.ask"],
88
108
  provider: "tjs",
89
109
  source: { modelId: "onnx-community/LFM2-VL-450M-ONNX" },
@@ -97,7 +117,211 @@ export const VISION_RECORDS = [
97
117
  commercial: "unknown",
98
118
  place: "gpu",
99
119
  runtime: "@huggingface/transformers@4.3.2",
100
- notes: ["earlier builds: q4f16 on webgpu only; the licence limits commercial use by revenue, read it before shipping"],
120
+ notes: ["q4f16 on webgpu only; the licence limits commercial use by revenue, read it before shipping"],
121
+ },
122
+ ];
123
+ /**
124
+ * Records listed for pickers and never registered by default, so a hub's
125
+ * routing by capability keeps its small defaults: larger alternates (smolvlm 500m and 2 video, gemma 4 e2b, two more
126
+ * depth models), and records under licences that limit use (YOLOv10 and
127
+ * FastSAM are AGPL-3.0 upstream, Ultralytics; the face swap set is
128
+ * InsightFace, non-commercial). A hub that runs one adds it itself. Sizes
129
+ * are the hub listings' files (vendor, 2026-11-25), in MiB.
130
+ */
131
+ const yolo10 = (size, mb, speed, verdict) => ({
132
+ id: `yolov10${size}`,
133
+ label: `yolov10 ${({ n: "nano", s: "small", m: "medium" })[size]}`,
134
+ group: size === "n" ? "tiny" : "good",
135
+ speed,
136
+ verdict,
137
+ provides: ["detect"],
138
+ provider: "ort",
139
+ source: { repo: `onnx-community/yolov10${size}`, file: "onnx/model.onnx" },
140
+ sizeMB: mb,
141
+ sizeSource: "vendor",
142
+ ladder: [
143
+ { device: "webgpu", ort: { executionProviders: ["webgpu", "wasm"] } },
144
+ { device: "wasm", ort: { executionProviders: ["wasm"] } },
145
+ ],
146
+ licence: "AGPL-3.0 (Ultralytics weights, the model card's licence field)",
147
+ commercial: false,
148
+ place: "gpu",
149
+ notes: ["output [1, 300, 6] after the model's own selection, so no nms pass (vendor, the yolov10 paper)", "comes in nano, small and medium"],
150
+ });
151
+ /** Records listed for pickers and never registered by default: larger alternates, and records under licences that limit use (YOLOv10, FastSAM, the face swap set). */
152
+ export const PICKER_RECORDS = [
153
+ {
154
+ id: "smolvlm-500m-instruct",
155
+ label: "smolvlm 500m",
156
+ speed: "steady",
157
+ verdict: "better captions, slower",
158
+ group: "good",
159
+ provides: ["vision.caption", "vision.ask"],
160
+ provider: "tjs",
161
+ source: { modelId: "HuggingFaceTB/SmolVLM-500M-Instruct" },
162
+ // q4 decoder 229.1, q4 vision 66.7, q4 embed 189.2 MB in the onnx folder of the hub listing (vendor, 2026-11-25)
163
+ sizeMB: 463,
164
+ sizeSource: "vendor",
165
+ ladder: LADDERS.smolvlm(),
166
+ quirks: { repetitionPenalty: 1.3, maxTokensAction: 64 },
167
+ licence: "Apache-2.0",
168
+ commercial: true,
169
+ place: "cpu-worker",
170
+ runtime: "@huggingface/transformers@4.3.2",
171
+ },
172
+ {
173
+ id: "smolvlm2-256m-video-instruct",
174
+ label: "smolvlm2 256m video",
175
+ speed: "fast",
176
+ verdict: "watches short clips",
177
+ group: "tiny",
178
+ provides: ["vision.caption", "vision.ask"],
179
+ provider: "tjs",
180
+ source: { modelId: "HuggingFaceTB/SmolVLM2-256M-Video-Instruct" },
181
+ // q4 decoder 86.9, q4 vision 63.8, q4 embed 113.5 MB in the hub listing (vendor, 2026-11-25), in MiB
182
+ sizeMB: 252,
183
+ sizeSource: "vendor",
184
+ ladder: LADDERS.smolvlm(),
185
+ quirks: { repetitionPenalty: 1.3, maxTokensAction: 64 },
186
+ licence: "Apache-2.0",
187
+ commercial: true,
188
+ place: "cpu-worker",
189
+ runtime: "@huggingface/transformers@4.3.2",
190
+ notes: ["an option beside smolvlm 256m and 500m"],
191
+ },
192
+ {
193
+ id: "depth-anything-v2-base",
194
+ label: "depth anything v2 base",
195
+ speed: "steady",
196
+ verdict: "finer depth, non commercial",
197
+ group: "good",
198
+ provides: ["depth"],
199
+ provider: "tjs",
200
+ source: { modelId: "onnx-community/depth-anything-v2-base" },
201
+ // model_fp16.onnx 194.6 MB, model.onnx 388.9 MB in the hub listing (vendor, 2026-11-25); the first rung loads fp16
202
+ sizeMB: 186,
203
+ sizeSource: "vendor",
204
+ ladder: LADDERS.depth(),
205
+ licence: "CC-BY-NC-4.0 (the model card's licence field)",
206
+ commercial: false,
207
+ place: "cpu-worker",
208
+ runtime: "@huggingface/transformers@4.3.2",
209
+ },
210
+ {
211
+ id: "depth-anything-small-v1",
212
+ label: "depth anything v1 small",
213
+ speed: "fast",
214
+ verdict: "the first version",
215
+ group: "tiny",
216
+ provides: ["depth"],
217
+ provider: "tjs",
218
+ source: { modelId: "Xenova/depth-anything-small-hf" },
219
+ // model_fp16.onnx 49.9 MB in the hub listing (vendor, 2026-11-25)
220
+ sizeMB: 48,
221
+ sizeSource: "vendor",
222
+ ladder: LADDERS.depth(),
223
+ licence: "Apache-2.0 (the upstream card; this export's card has no licence field)",
224
+ commercial: "unknown",
225
+ place: "cpu-worker",
226
+ runtime: "@huggingface/transformers@4.3.2",
227
+ },
228
+ {
229
+ id: "gemma-4-e2b-vision",
230
+ label: "gemma 4 e2b",
231
+ speed: "slow",
232
+ verdict: "sees most, heavy",
233
+ group: "good",
234
+ provides: ["vision.caption", "vision.ask"],
235
+ provider: "tjs",
236
+ source: { modelId: "onnx-community/gemma-4-E2B-it-ONNX" },
237
+ // q4 decoder, vision and embed graphs with their external data, no audio encoder: 3739.7 MB in the hub listing (vendor, 2026-11-25)
238
+ sizeMB: 3566,
239
+ sizeSource: "vendor",
240
+ ladder: LADDERS.vlmGpuOnly(),
241
+ quirks: { systemRole: false, strictAlternation: true, maxTokensAction: 96 },
242
+ licence: "Apache-2.0 (the model card's licence field)",
243
+ commercial: true,
244
+ place: "gpu",
245
+ runtime: "@huggingface/transformers@4.3.2",
246
+ notes: ["about 3.3 GB (vendor)"],
247
+ },
248
+ yolo10("n", 9, "instant", "nano, quick"),
249
+ yolo10("s", 28, "fast", "small, sharper"),
250
+ yolo10("m", 59, "steady", "medium, best boxes"),
251
+ {
252
+ id: "fastsam-s",
253
+ label: "fastsam s",
254
+ speed: "fast",
255
+ verdict: "finds everything, cpu ok",
256
+ group: "good",
257
+ provides: ["segment.everything"],
258
+ provider: "ort",
259
+ source: { repo: "anakhiu/fastsam-onnx", file: "fastsam_s.onnx" },
260
+ sizeMB: 45,
261
+ sizeSource: "vendor",
262
+ ladder: [
263
+ { device: "webgpu", ort: { executionProviders: ["webgpu", "wasm"] } },
264
+ { device: "wasm", ort: { executionProviders: ["wasm"] } },
265
+ ],
266
+ licence: "AGPL-3.0 upstream (Ultralytics FastSAM); the export's card says apache-2.0",
267
+ commercial: false,
268
+ place: "cpu-worker",
269
+ notes: ["finds every mask in one pass on onnxruntime-web (93 MB, vendor)", "segment everything: prototype masks, nms, then a pick by click"],
270
+ },
271
+ {
272
+ id: "scrfd-10g",
273
+ label: "face finder (scrfd 10g)",
274
+ speed: "fast",
275
+ verdict: "finds faces",
276
+ group: "start here",
277
+ provides: ["face.detect"],
278
+ provider: "ort",
279
+ source: { repo: "immich-app/buffalo_l", file: "detection/model.onnx" },
280
+ sizeMB: 16,
281
+ sizeSource: "vendor",
282
+ ladder: [{ device: "wasm", ort: { executionProviders: ["wasm"] } }],
283
+ licence: "InsightFace model pack: non-commercial research only (the buffalo_l pack terms)",
284
+ commercial: false,
285
+ place: "cpu-worker",
286
+ },
287
+ {
288
+ id: "arcface-w600k-r50",
289
+ label: "face id (arcface r50)",
290
+ speed: "steady",
291
+ verdict: "who is who",
292
+ group: "start here",
293
+ provides: ["face.embed"],
294
+ provider: "ort",
295
+ source: { repo: "immich-app/buffalo_l", file: "recognition/model.onnx" },
296
+ sizeMB: 166,
297
+ sizeSource: "vendor",
298
+ ladder: [
299
+ { device: "webgpu", ort: { executionProviders: ["webgpu", "wasm"] } },
300
+ { device: "wasm", ort: { executionProviders: ["wasm"] } },
301
+ ],
302
+ licence: "InsightFace model pack: non-commercial research only (the buffalo_l pack terms)",
303
+ commercial: false,
304
+ place: "cpu-worker",
305
+ },
306
+ {
307
+ id: "inswapper-128",
308
+ label: "face swap (inswapper 128)",
309
+ speed: "slow",
310
+ verdict: "the swap itself",
311
+ group: "start here",
312
+ provides: ["face.swap"],
313
+ provider: "ort",
314
+ source: { repo: "hacksider/inswapper_128", file: "inswapper_128.onnx" },
315
+ sizeMB: 529,
316
+ sizeSource: "vendor",
317
+ ladder: [
318
+ { device: "webgpu", ort: { executionProviders: ["webgpu", "wasm"] } },
319
+ { device: "wasm", ort: { executionProviders: ["wasm"] } },
320
+ ],
321
+ licence: "InsightFace: non-commercial research only; the mirror's card says gpl-3.0",
322
+ commercial: false,
323
+ place: "gpu",
324
+ notes: ["128 px faces; paste the result back with a feathered mask"],
101
325
  },
102
326
  ];
103
327
  /** A face landmark fallback record over face-api.js tiny nets (code MIT; weights MIT from @vladmandic/face-api). */
@@ -105,6 +329,9 @@ export function faceApiRecord(baseUrl) {
105
329
  return {
106
330
  id: "face-api-tiny",
107
331
  label: "face-api tiny landmarks (68 points)",
332
+ speed: "instant",
333
+ verdict: "68 points, cpu",
334
+ group: "cpu",
108
335
  provides: ["landmarks.face"],
109
336
  provider: "faceapi",
110
337
  source: { url: baseUrl },
@@ -121,6 +348,9 @@ export function yoloRecord(o) {
121
348
  return {
122
349
  id: o.id ?? "yolov8n",
123
350
  label: "yolov8n (external)",
351
+ group: "tiny",
352
+ speed: "instant",
353
+ verdict: "nano, your file",
124
354
  provides: ["detect"],
125
355
  provider: "ort",
126
356
  source: { url: o.url, ...(o.sha256 ? { sha256: o.sha256 } : {}) },
@@ -133,6 +363,6 @@ export function yoloRecord(o) {
133
363
  licence: o.licence ?? "AGPL-3.0 (Ultralytics YOLOv8 weights), supplied by the app",
134
364
  commercial: false,
135
365
  place: "gpu",
136
- notes: ["earlier builds: 640 letterbox, per class nms at iou 0.45, at most 13 boxes"],
366
+ notes: ["640 letterbox, per class nms at iou 0.45, at most 13 boxes"],
137
367
  };
138
368
  }