@hackbuild/ai-views 0.1.18 → 0.1.20

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.
@@ -3061,6 +3061,282 @@ var HackbuildAiViews = (function(exports) {
3061
3061
  "vendor"
3062
3062
  ]
3063
3063
  }
3064
+ },
3065
+ "onnx-community/Qwen3.5-0.8B-ONNX-OPT": {
3066
+ "revision": "9a4c21d8f724176b0a7edaaed36303044451886e",
3067
+ "files": {
3068
+ "config.json": [
3069
+ "36fed6a902ccd06ef19a452bd5a0750bd88fe347d06ab75ef515615bac5b296d",
3070
+ 2849,
3071
+ "measured"
3072
+ ],
3073
+ "generation_config.json": [
3074
+ "dc0cbe66543f310896469b7b1448af792f403293a1080baaf04d586c57b23e48",
3075
+ 248,
3076
+ "measured"
3077
+ ],
3078
+ "onnx/decoder_model_merged_q4.onnx": [
3079
+ "7390858c80a67275d8cb81fb70f66a24d3b86fe333057c1312de09c184a2d41b",
3080
+ 576621,
3081
+ "vendor"
3082
+ ],
3083
+ "onnx/decoder_model_merged_q4.onnx_data": [
3084
+ "1a9165072dd51a9b6a917b6357a3686372b7429313022802cd4c9a730e8c9749",
3085
+ 483655680,
3086
+ "vendor"
3087
+ ],
3088
+ "onnx/decoder_model_merged_q4f16.onnx": [
3089
+ "bd556c6ba812cb7c46328d0caf05e9c3a7e3b8b644add85ae21ad7054524d387",
3090
+ 697833,
3091
+ "vendor"
3092
+ ],
3093
+ "onnx/decoder_model_merged_q4f16.onnx_data": [
3094
+ "e3459410bf09b756150fb590778f09a52dda85ca1426f65ecac18192fac18b91",
3095
+ 435777536,
3096
+ "vendor"
3097
+ ],
3098
+ "onnx/embed_tokens_q4.onnx": [
3099
+ "8773dcf4858f855bfce13def4356ca17e0bc516a477154496b6ffb6dd6d084dc",
3100
+ 857,
3101
+ "vendor"
3102
+ ],
3103
+ "onnx/embed_tokens_q4.onnx_data": [
3104
+ "9210b1d26eb14136d3522584d17da14cc5f4b82b6f5607e6d80d59424a8cbe99",
3105
+ 162897920,
3106
+ "vendor"
3107
+ ],
3108
+ "onnx/embed_tokens_q4f16.onnx": [
3109
+ "8218531ac44ae9978d50647f1d907c53c308f758514b992504238c77843c254d",
3110
+ 1064,
3111
+ "vendor"
3112
+ ],
3113
+ "onnx/embed_tokens_q4f16.onnx_data": [
3114
+ "ec4a1f13ff942653b52000a7a0ec40504110d8be9a0ecab2da4d3063588ed563",
3115
+ 147005440,
3116
+ "vendor"
3117
+ ],
3118
+ "onnx/vision_encoder_q4.onnx": [
3119
+ "9b62022e77de4b22ca0bbc4453083c0cdeb8f967ccf13931d4c24c6e7c776177",
3120
+ 185278,
3121
+ "vendor"
3122
+ ],
3123
+ "onnx/vision_encoder_q4.onnx_data": [
3124
+ "98aebedf02fc5414fd1c7f06a6580b42e272600ace9ecd33bfbc479a0c541c64",
3125
+ 68267008,
3126
+ "vendor"
3127
+ ],
3128
+ "onnx/vision_encoder_q4f16.onnx": [
3129
+ "1e76d0c16c1c196e7e6f33053284369e0bc82b10bdc2f14bdf103f86ae5eb11a",
3130
+ 213118,
3131
+ "vendor"
3132
+ ],
3133
+ "onnx/vision_encoder_q4f16.onnx_data": [
3134
+ "0847376fcef41cb3874a21f0eb1b75428502537e16f360bdbf854e71ef552319",
3135
+ 61919744,
3136
+ "vendor"
3137
+ ],
3138
+ "preprocessor_config.json": [
3139
+ "6a970fd06f30e6943b3e2c14d5d3b42d49b06cf99b99103d56689bef462d90f8",
3140
+ 336,
3141
+ "measured"
3142
+ ],
3143
+ "processor_config.json": [
3144
+ "14932921ca485d458a04dafd8069fbb0a4505622a48208d19ed247115801385b",
3145
+ 1300,
3146
+ "measured"
3147
+ ],
3148
+ "tokenizer.json": [
3149
+ "89da80cc6689bef4d90cc1028249436975ffb0814618f1d93c65310e05801a9b",
3150
+ 19226111,
3151
+ "vendor"
3152
+ ],
3153
+ "tokenizer_config.json": [
3154
+ "5dcac2c1306b11d1e18ec4c024a174bded2ca3178ce87b0aa590711696407f3d",
3155
+ 10069,
3156
+ "measured"
3157
+ ]
3158
+ }
3159
+ },
3160
+ "onnx-community/Qwen3.5-2B-ONNX": {
3161
+ "revision": "315216e893038beefcc6eba41ac168913dd0d879",
3162
+ "files": {
3163
+ "config.json": [
3164
+ "b028de63b0ed8b37107acaaf1475d40d6d4feb5721153674e7d1d0bdbfd0f258",
3165
+ 2993,
3166
+ "measured"
3167
+ ],
3168
+ "generation_config.json": [
3169
+ "dc0cbe66543f310896469b7b1448af792f403293a1080baaf04d586c57b23e48",
3170
+ 248,
3171
+ "measured"
3172
+ ],
3173
+ "onnx/decoder_model_merged_q4.onnx": [
3174
+ "33f9c1311878df2140e7286f76d9e3acb29d77d91f724210674b0b63d8330df5",
3175
+ 885982,
3176
+ "vendor"
3177
+ ],
3178
+ "onnx/decoder_model_merged_q4.onnx_data": [
3179
+ "c6f4807e1287961a354b0bc6f8d4c68c658f707a9541e771a297dfefaf4a1e14",
3180
+ 1209126912,
3181
+ "vendor"
3182
+ ],
3183
+ "onnx/decoder_model_merged_q4f16.onnx": [
3184
+ "aff64289c18b527ee16963444be405d08e7211c4fdca6f3fe53d9d4586703bf7",
3185
+ 1046438,
3186
+ "vendor"
3187
+ ],
3188
+ "onnx/decoder_model_merged_q4f16.onnx_data": [
3189
+ "e0d1375a8d30aa7db927ce05c60c4134345dca61150acdf05b9822bc06c7e54b",
3190
+ 1089777664,
3191
+ "vendor"
3192
+ ],
3193
+ "onnx/embed_tokens_q4.onnx": [
3194
+ "0255dd844858758f452d9678f1e2c91db178f21b7da254d29b12e7fe3d23e305",
3195
+ 857,
3196
+ "vendor"
3197
+ ],
3198
+ "onnx/embed_tokens_q4.onnx_data": [
3199
+ "9a6404d9b1c79ffc038d5c28deec04d419efb4594125453c991be38b4522ecb6",
3200
+ 325795840,
3201
+ "vendor"
3202
+ ],
3203
+ "onnx/embed_tokens_q4f16.onnx": [
3204
+ "802a072ff21f540eda7f343aa71dbb0354c8859caaf34f09b3bf8117725d7de8",
3205
+ 1064,
3206
+ "vendor"
3207
+ ],
3208
+ "onnx/embed_tokens_q4f16.onnx_data": [
3209
+ "650aa8eb39b7404ca2c908d78243c82b6fd88321feeb8fca175745806c6b3a81",
3210
+ 294010880,
3211
+ "vendor"
3212
+ ],
3213
+ "onnx/vision_encoder_q4.onnx": [
3214
+ "7ccbf866b2e0d0c59272c741715fd78764c8777f1063efe070d420191255c9fe",
3215
+ 338758,
3216
+ "vendor"
3217
+ ],
3218
+ "onnx/vision_encoder_q4.onnx_data": [
3219
+ "0ea0ab9559904e1e5150a0ca194136922c6b8f1dfaaa44cc5e174ca59b231bb3",
3220
+ 217952256,
3221
+ "vendor"
3222
+ ],
3223
+ "onnx/vision_encoder_q4f16.onnx": [
3224
+ "805dd77fc1501ce100574dd81d9181f9ce95def7f25c52fda99a5cbb9b691ae9",
3225
+ 393718,
3226
+ "vendor"
3227
+ ],
3228
+ "onnx/vision_encoder_q4f16.onnx_data": [
3229
+ "c54ed06141904a99fa05a9ffaf460ee05441d50dde54f784ec2ae71a43c58314",
3230
+ 196945920,
3231
+ "vendor"
3232
+ ],
3233
+ "preprocessor_config.json": [
3234
+ "6a970fd06f30e6943b3e2c14d5d3b42d49b06cf99b99103d56689bef462d90f8",
3235
+ 336,
3236
+ "measured"
3237
+ ],
3238
+ "processor_config.json": [
3239
+ "14932921ca485d458a04dafd8069fbb0a4505622a48208d19ed247115801385b",
3240
+ 1300,
3241
+ "measured"
3242
+ ],
3243
+ "tokenizer.json": [
3244
+ "89da80cc6689bef4d90cc1028249436975ffb0814618f1d93c65310e05801a9b",
3245
+ 19226111,
3246
+ "vendor"
3247
+ ],
3248
+ "tokenizer_config.json": [
3249
+ "5dcac2c1306b11d1e18ec4c024a174bded2ca3178ce87b0aa590711696407f3d",
3250
+ 10069,
3251
+ "measured"
3252
+ ]
3253
+ }
3254
+ },
3255
+ "onnx-community/Janus-Pro-1B-ONNX": {
3256
+ "revision": "04efdf2e36cb07a034b0d94f7322356b292f0418",
3257
+ "files": {
3258
+ "config.json": [
3259
+ "211520b35aa61bbc07db2cbdc9584abceb2b19d26ae5219998ad50037d6a9d71",
3260
+ 1888,
3261
+ "measured"
3262
+ ],
3263
+ "generation_config.json": [
3264
+ "44328aebd31137f591cce9bf3c82a290785e18cb293e99f2410de52b78f04066",
3265
+ 167,
3266
+ "measured"
3267
+ ],
3268
+ "onnx/gen_head_fp16.onnx": [
3269
+ "59563c2c872555def6959653ad078bfe93d3484f6f9e692e25160ac2dadf4eae",
3270
+ 75536078,
3271
+ "vendor"
3272
+ ],
3273
+ "onnx/gen_img_embeds_fp16.onnx": [
3274
+ "1501cac82ce8d4b26b27af5f9f993b1575e27a42a09d07ac508feaebb79aedde",
3275
+ 8695058,
3276
+ "vendor"
3277
+ ],
3278
+ "onnx/image_decode.onnx": [
3279
+ "5395223c9212df6dca1f29a540f7c5c78971c0d2ee7a3ac88a4e8f5f2b227fb8",
3280
+ 170460651,
3281
+ "vendor"
3282
+ ],
3283
+ "onnx/language_model_q4f16.onnx": [
3284
+ "bda78684bd85d4beda5558179e2a5da960f13969f111a8024f75be11cdef9a61",
3285
+ 698231365,
3286
+ "vendor"
3287
+ ],
3288
+ "onnx/lm_head_fp16.onnx": [
3289
+ "215ccbdb0efd6067e68b3057ba798802727d36795b064fd95dea5a4c79f8a733",
3290
+ 419430700,
3291
+ "vendor"
3292
+ ],
3293
+ "onnx/prepare_inputs_embeds_q4.onnx": [
3294
+ "380c548a75687004c47f7a988f474d03d052b2154292e2a4d001d74d4d2cc845",
3295
+ 1038802881,
3296
+ "vendor"
3297
+ ],
3298
+ "preprocessor_config.json": [
3299
+ "4dae4dc1bda762bdc84b887b2d3339f21935a15ff716b3049490d96935f7f12a",
3300
+ 346,
3301
+ "measured"
3302
+ ],
3303
+ "processor_config.json": [
3304
+ "0e9cc77ac444a91691215ac4e61d2c832b25c44ab006f1b7c85b91880478c5c4",
3305
+ 288,
3306
+ "measured"
3307
+ ],
3308
+ "special_tokens_map.json": [
3309
+ "0db13daead5880bf635018dd15996e4dbe7b4333860794cee2b5d6559edaecae",
3310
+ 344,
3311
+ "measured"
3312
+ ],
3313
+ "tokenizer.json": [
3314
+ "cd187abdb6927a04ff0214b2d3fa05f4131de66298c8b3b75fbc25ce5f7faff2",
3315
+ 4718995,
3316
+ "measured"
3317
+ ],
3318
+ "tokenizer_config.json": [
3319
+ "e72af0754f6460a71590afaae8e9666e709eabc35cd2a68fcd2a349f06bbd53e",
3320
+ 1355,
3321
+ "measured"
3322
+ ]
3323
+ }
3324
+ },
3325
+ "ggml-org/gemma-4-E2B-it-GGUF": {
3326
+ "revision": "2a8538c2e2d4687953a86c422c7c623cfd022880",
3327
+ "files": { "gemma-4-E2B-it-Q4_0.gguf": [
3328
+ "8e30dff3ac4c8434c49a7036fa15564bdbb6044e42bf04550bf1a096ad7e6a52",
3329
+ 2841481184,
3330
+ "vendor"
3331
+ ] }
3332
+ },
3333
+ "ggml-org/Qwen3.5-0.8B-GGUF": {
3334
+ "revision": "1c0b5292de5ccd62235595d1557c0d70d46c3d9d",
3335
+ "files": { "Qwen3.5-0.8B-Q4_0.gguf": [
3336
+ "57d1997790d1744fba5b40a7317df71ea5e2acee28c47e78f0cce39c0703f8cf",
3337
+ 563036064,
3338
+ "vendor"
3339
+ ] }
3064
3340
  }
3065
3341
  };
3066
3342
  }));
@@ -3997,6 +4273,184 @@ var HackbuildAiViews = (function(exports) {
3997
4273
  commercial: "unknown",
3998
4274
  runtime: "@wllama/wllama@3.8.1"
3999
4275
  },
4276
+ {
4277
+ id: "gemma-4-e2b-it-mlc",
4278
+ label: "Gemma 4 E2B",
4279
+ params: "E2B",
4280
+ quant: "q4f16_1",
4281
+ vramMB: 3387,
4282
+ vramSource: "vendor",
4283
+ censorship: "stock",
4284
+ tier: "medium",
4285
+ family: "gemma",
4286
+ tags: [],
4287
+ note: "google's gemma 4, the small one. text here; images run through the vision records.",
4288
+ group: "good",
4289
+ badge: "newest gemma",
4290
+ speed: "steady",
4291
+ verdict: "newest gemma, heavier",
4292
+ provides: ["chat"],
4293
+ provider: "webllm",
4294
+ source: { modelId: "gemma-4-E2B-it-q4f16_1-MLC" },
4295
+ sizeMB: 2700,
4296
+ sizeSource: "vendor",
4297
+ ctx: 4096,
4298
+ ladder: [{
4299
+ device: "webgpu",
4300
+ dtype: "q4f16_1",
4301
+ options: { modelId: "gemma-4-E2B-it-q4f16_1-MLC" }
4302
+ }, {
4303
+ device: "webgpu",
4304
+ dtype: "q4f32_1",
4305
+ options: { modelId: "gemma-4-E2B-it-q4f32_1-MLC" }
4306
+ }],
4307
+ quirks: { think: "none" },
4308
+ licence: "Apache-2.0 (the base model card)",
4309
+ commercial: true,
4310
+ runtime: "@mlc-ai/web-llm@0.2.86",
4311
+ notes: ["web-llm 0.2.86 or later lists it (vendor)"]
4312
+ },
4313
+ {
4314
+ id: "gemma-4-e2b-it-gguf",
4315
+ label: "Gemma 4 E2B",
4316
+ params: "E2B",
4317
+ quant: "Q4_0",
4318
+ censorship: "stock",
4319
+ tier: "medium",
4320
+ family: "gemma",
4321
+ tags: [],
4322
+ note: "google's gemma 4 e2b from ggml-org, the llama.cpp project's own build.",
4323
+ group: "good",
4324
+ badge: "newest gemma, gguf",
4325
+ speed: "steady",
4326
+ verdict: "newest gemma, gguf",
4327
+ provides: ["chat"],
4328
+ provider: "wllama",
4329
+ source: {
4330
+ repo: "ggml-org/gemma-4-E2B-it-GGUF",
4331
+ file: "gemma-4-E2B-it-Q4_0.gguf"
4332
+ },
4333
+ sizeMB: 2710,
4334
+ sizeSource: "vendor",
4335
+ ladder: [{
4336
+ device: "webgpu",
4337
+ dtype: "q4_0"
4338
+ }, {
4339
+ device: "wasm",
4340
+ dtype: "q4_0"
4341
+ }],
4342
+ quirks: { think: "none" },
4343
+ licence: "Apache-2.0 (the base model card)",
4344
+ commercial: true,
4345
+ runtime: "@wllama/wllama@3.8.1"
4346
+ },
4347
+ {
4348
+ id: "qwen3.5-0.8b-mlc",
4349
+ label: "Qwen3.5 0.8B",
4350
+ params: "0.8B",
4351
+ quant: "q4f32_1",
4352
+ vramMB: 1894,
4353
+ vramSource: "vendor",
4354
+ censorship: "stock",
4355
+ tier: "small",
4356
+ family: "qwen3.5",
4357
+ tags: ["low vram"],
4358
+ note: "the smallest qwen3.5. text in this runtime; images run through the vision records.",
4359
+ group: "tiny",
4360
+ badge: "newest qwen, small",
4361
+ speed: "fast",
4362
+ verdict: "newest qwen, small",
4363
+ provides: ["chat"],
4364
+ provider: "webllm",
4365
+ source: { modelId: "Qwen3.5-0.8B-q4f32_1-MLC" },
4366
+ sizeMB: 427,
4367
+ sizeSource: "vendor",
4368
+ ctx: 4096,
4369
+ ladder: [{
4370
+ device: "webgpu",
4371
+ dtype: "q4f32_1",
4372
+ options: { modelId: "Qwen3.5-0.8B-q4f32_1-MLC" }
4373
+ }, {
4374
+ device: "webgpu",
4375
+ dtype: "q4f16_1",
4376
+ options: { modelId: "Qwen3.5-0.8B-q4f16_1-MLC" }
4377
+ }],
4378
+ quirks: { toolCallTags: true },
4379
+ licence: "Apache-2.0 (the base model card)",
4380
+ commercial: true,
4381
+ runtime: "@mlc-ai/web-llm@0.2.84",
4382
+ notes: ["weak at this size: the 2b answers well (measured 2026-12-02)"]
4383
+ },
4384
+ {
4385
+ id: "qwen3.5-2b-mlc",
4386
+ label: "Qwen3.5 2B",
4387
+ params: "2B",
4388
+ quant: "q4f16_1",
4389
+ vramMB: 2245,
4390
+ vramSource: "vendor",
4391
+ censorship: "stock",
4392
+ tier: "small",
4393
+ family: "qwen3.5",
4394
+ tags: [],
4395
+ note: "qwen3.5 2b. text in this runtime; images run through the vision records.",
4396
+ group: "good",
4397
+ badge: "newest qwen",
4398
+ speed: "fast",
4399
+ verdict: "newest qwen, balanced",
4400
+ provides: ["chat"],
4401
+ provider: "webllm",
4402
+ source: { modelId: "Qwen3.5-2B-q4f16_1-MLC" },
4403
+ sizeMB: 1032,
4404
+ sizeSource: "vendor",
4405
+ ctx: 4096,
4406
+ ladder: [{
4407
+ device: "webgpu",
4408
+ dtype: "q4f16_1",
4409
+ options: { modelId: "Qwen3.5-2B-q4f16_1-MLC" }
4410
+ }, {
4411
+ device: "webgpu",
4412
+ dtype: "q4f32_1",
4413
+ options: { modelId: "Qwen3.5-2B-q4f32_1-MLC" }
4414
+ }],
4415
+ quirks: { toolCallTags: true },
4416
+ licence: "Apache-2.0 (the base model card)",
4417
+ commercial: true,
4418
+ runtime: "@mlc-ai/web-llm@0.2.84"
4419
+ },
4420
+ {
4421
+ id: "qwen3.5-0.8b-gguf",
4422
+ label: "Qwen3.5 0.8B",
4423
+ params: "0.8B",
4424
+ quant: "Q4_0",
4425
+ censorship: "stock",
4426
+ tier: "small",
4427
+ family: "qwen3.5",
4428
+ tags: ["no gpu"],
4429
+ note: "the smallest qwen3.5 from ggml-org. runs on the cpu too.",
4430
+ group: "tiny",
4431
+ badge: "newest qwen, cpu",
4432
+ speed: "fast",
4433
+ verdict: "newest qwen, cpu",
4434
+ provides: ["chat"],
4435
+ provider: "wllama",
4436
+ source: {
4437
+ repo: "ggml-org/Qwen3.5-0.8B-GGUF",
4438
+ file: "Qwen3.5-0.8B-Q4_0.gguf"
4439
+ },
4440
+ sizeMB: 537,
4441
+ sizeSource: "vendor",
4442
+ ladder: [{
4443
+ device: "webgpu",
4444
+ dtype: "q4_0"
4445
+ }, {
4446
+ device: "wasm",
4447
+ dtype: "q4_0"
4448
+ }],
4449
+ quirks: { toolCallTags: true },
4450
+ licence: "Apache-2.0 (the base model card)",
4451
+ commercial: true,
4452
+ runtime: "@wllama/wllama@3.8.1"
4453
+ },
4000
4454
  {
4001
4455
  id: "qwen3.5-0.8b-abliterated-gguf",
4002
4456
  label: "Qwen3.5 0.8B abliterated",
@@ -8178,6 +8632,67 @@ var HackbuildAiViews = (function(exports) {
8178
8632
  ids2: "int64"
8179
8633
  }
8180
8634
  }
8635
+ }, {
8636
+ id: "janus-pro-1b",
8637
+ label: "janus-pro 1b 384",
8638
+ speed: "slow",
8639
+ verdict: "draws and sees",
8640
+ group: "good",
8641
+ provides: ["imagegen"],
8642
+ provider: "tjs",
8643
+ source: { modelId: "onnx-community/Janus-Pro-1B-ONNX" },
8644
+ sizeMB: 2304,
8645
+ sizeSource: "vendor",
8646
+ ladder: [{
8647
+ device: "webgpu",
8648
+ dtype: {
8649
+ prepare_inputs_embeds: "q4",
8650
+ language_model: "q4f16",
8651
+ lm_head: "fp16",
8652
+ gen_head: "fp16",
8653
+ gen_img_embeds: "fp16",
8654
+ image_decode: "fp32"
8655
+ },
8656
+ options: {
8657
+ loader: "imagegen.janus",
8658
+ device: {
8659
+ prepare_inputs_embeds: "wasm",
8660
+ language_model: "webgpu",
8661
+ lm_head: "webgpu",
8662
+ gen_head: "webgpu",
8663
+ gen_img_embeds: "webgpu",
8664
+ image_decode: "webgpu"
8665
+ }
8666
+ }
8667
+ }],
8668
+ licence: "DeepSeek Model License (weights; use restrictions apply), MIT (code)",
8669
+ commercial: true,
8670
+ place: "gpu",
8671
+ runtime: "@huggingface/transformers@4.3.2",
8672
+ notes: [
8673
+ "deepseek's janus-pro: one model that reads images and draws them, 576 image tokens per picture",
8674
+ "janus-pro 7b draws only through deepseek's python code; no browser or openai style build draws (vendor)",
8675
+ "needs shader-f16 on webgpu; transformers.js samples, so a seed does not repeat a picture"
8676
+ ],
8677
+ form: {
8678
+ steps: {
8679
+ min: 1,
8680
+ max: 1,
8681
+ default: 1
8682
+ },
8683
+ guidance: null,
8684
+ negative: false,
8685
+ sizes: [384],
8686
+ spacing: "trailing",
8687
+ note: "janus-pro 1b, deepseek. draws 384 pixel pictures token by token.",
8688
+ tokenizer: "onnx-community/Janus-Pro-1B-ONNX",
8689
+ graphs: {
8690
+ textEncoder: "",
8691
+ unet: "",
8692
+ vaeDecoder: ""
8693
+ },
8694
+ pipeline: "janus"
8695
+ }
8181
8696
  }];
8182
8697
  }));
8183
8698
  // packages/imagegen/src/xl.ts
@@ -8343,10 +8858,77 @@ var HackbuildAiViews = (function(exports) {
8343
8858
  };
8344
8859
  EOT = 49407;
8345
8860
  }));
8861
+ // packages/imagegen/src/janus.ts
8862
+ /** RGB or RGBA pixels from transformers.js as RGBA. */
8863
+ function rgbaOf(img) {
8864
+ const n = img.width * img.height;
8865
+ if (img.channels === 4) return new Uint8ClampedArray(img.data);
8866
+ const out = new Uint8ClampedArray(n * 4);
8867
+ for (let i = 0; i < n; i++) {
8868
+ out[i * 4] = img.data[i * img.channels];
8869
+ out[i * 4 + 1] = img.data[i * img.channels + (img.channels > 1 ? 1 : 0)];
8870
+ out[i * 4 + 2] = img.data[i * img.channels + (img.channels > 2 ? 2 : 0)];
8871
+ out[i * 4 + 3] = 255;
8872
+ }
8873
+ return out;
8874
+ }
8875
+ /** The transformers.js loader for Janus image records, registered by `attachImagegen(hub, tjs)` as "imagegen.janus". */
8876
+ async function janusImageLoader(ctx) {
8877
+ const id = ctx.record.source.modelId;
8878
+ const P = ctx.tjs.AutoProcessor;
8879
+ const M = ctx.tjs.MultiModalityCausalLM;
8880
+ if (!P || !M) throw new Error("janus needs transformers.js 3.1.0 or later (MultiModalityCausalLM)");
8881
+ const processor = await P.from_pretrained(id);
8882
+ const model = await M.from_pretrained(id, ctx.options);
8883
+ return {
8884
+ async draw(prompt, o = {}) {
8885
+ const t0 = performance.now();
8886
+ const inputs = await processor([{
8887
+ role: "<|User|>",
8888
+ content: prompt
8889
+ }], { chat_template: "text_to_image" });
8890
+ const total = processor.num_image_tokens;
8891
+ o.signal?.throwIfAborted();
8892
+ let done = -1;
8893
+ const streamer = {
8894
+ put: () => {
8895
+ o.signal?.throwIfAborted();
8896
+ if (++done > 0) o.onToken?.(done, total);
8897
+ },
8898
+ end: () => {}
8899
+ };
8900
+ const t1 = performance.now();
8901
+ const [img] = await model.generate_images({
8902
+ ...inputs,
8903
+ min_new_tokens: total,
8904
+ max_new_tokens: total,
8905
+ do_sample: true,
8906
+ streamer
8907
+ });
8908
+ if (!img) throw new Error("janus returned no image");
8909
+ const t2 = performance.now();
8910
+ return {
8911
+ width: img.width,
8912
+ height: img.height,
8913
+ rgba: rgbaOf(img),
8914
+ seed: 0,
8915
+ seeded: false,
8916
+ ms: {
8917
+ text: t1 - t0,
8918
+ unet: t2 - t1,
8919
+ vae: 0
8920
+ }
8921
+ };
8922
+ },
8923
+ dispose: () => model.dispose?.()
8924
+ };
8925
+ }
8926
+ var init_janus$1 = __esmMin((() => {}));
8346
8927
  // packages/imagegen/src/hub.ts
8347
8928
  /** Add the image records to the hub's registry. */
8348
- function attachImagegen(hub) {
8929
+ function attachImagegen(hub, tjs) {
8349
8930
  hub.registry.add(...IMAGEGEN_RECORDS);
8931
+ tjs?.loader("imagegen.janus", janusImageLoader);
8350
8932
  }
8351
8933
  /** The sessions of a loaded model, by the form's graph names: three, or four with SDXL's second text encoder. */
8352
8934
  function sessionsOf(m, form) {
@@ -8394,6 +8976,7 @@ var HackbuildAiViews = (function(exports) {
8394
8976
  }
8395
8977
  const loaded = await hub.use(what, o);
8396
8978
  const form = formOf(loaded.record) ?? IMAGEGEN_RECORDS[0].form;
8979
+ if (form.pipeline === "janus") return janusGenerator(hub, loaded, form);
8397
8980
  let sessions;
8398
8981
  try {
8399
8982
  sessions = sessionsOf(loaded.value, form);
@@ -8463,11 +9046,40 @@ var HackbuildAiViews = (function(exports) {
8463
9046
  }
8464
9047
  };
8465
9048
  }
9049
+ /** The generator for a Janus record: no onnx sessions or tokenizer of its own; the prompt goes to the model's own processor. */
9050
+ function janusGenerator(hub, loaded, form) {
9051
+ return {
9052
+ loaded,
9053
+ record: loaded.record,
9054
+ form,
9055
+ sessions: {},
9056
+ async generate(_tokenize, req) {
9057
+ const { runOptions, signal, prompt, onStep } = req;
9058
+ const t0 = performance.now();
9059
+ return hub.run(loaded, () => loaded.value.draw(prompt, {
9060
+ ...signal ? { signal } : {},
9061
+ ...onStep ? { onToken: (step, steps) => onStep({
9062
+ stage: "denoise",
9063
+ step,
9064
+ steps,
9065
+ ms: performance.now() - t0
9066
+ }) } : {}
9067
+ }), {
9068
+ ...runOptions ?? {},
9069
+ ...signal ? { signal } : {}
9070
+ });
9071
+ },
9072
+ release() {
9073
+ hub.release(loaded);
9074
+ }
9075
+ };
9076
+ }
8466
9077
  var FormError;
8467
9078
  var init_hub = __esmMin((() => {
8468
9079
  init_pipeline();
8469
9080
  init_records$3();
8470
9081
  init_xl();
9082
+ init_janus$1();
8471
9083
  FormError = class extends Error {
8472
9084
  name = "FormError";
8473
9085
  };
@@ -8489,12 +9101,14 @@ var HackbuildAiViews = (function(exports) {
8489
9101
  gaussian: () => gaussian,
8490
9102
  generate: () => generate,
8491
9103
  generateXl: () => generateXl,
9104
+ janusImageLoader: () => janusImageLoader,
8492
9105
  leadingTimesteps: () => leadingTimesteps,
8493
9106
  loadImagegen: () => loadImagegen,
8494
9107
  loadLabel: () => loadLabel,
8495
9108
  mulberry32: () => mulberry32,
8496
9109
  padIds: () => padIds,
8497
9110
  padIds2: () => padIds2,
9111
+ rgbaOf: () => rgbaOf,
8498
9112
  sessionsOf: () => sessionsOf,
8499
9113
  sigmas: () => sigmas,
8500
9114
  stubImagegenModel: () => stubImagegenModel,
@@ -8508,6 +9122,7 @@ var HackbuildAiViews = (function(exports) {
8508
9122
  init_records$3();
8509
9123
  init_hub();
8510
9124
  init_xl();
9125
+ init_janus$1();
8511
9126
  }));
8512
9127
  // packages/speak/src/text.ts
8513
9128
  /**
@@ -12562,7 +13177,7 @@ var HackbuildAiViews = (function(exports) {
12562
13177
  notes: ["640 letterbox, per class nms at iou 0.45, at most 13 boxes"]
12563
13178
  };
12564
13179
  }
12565
- var MP_MODELS, mediapipeLadder, mp, VISION_RECORDS, yolo10, PICKER_RECORDS;
13180
+ var MP_MODELS, mediapipeLadder, mp, VISION_RECORDS, yolo10, PICKER_RECORDS, ENDPOINT_RECORDS;
12566
13181
  var init_records = __esmMin((() => {
12567
13182
  init_src$9();
12568
13183
  MP_MODELS = "https://storage.googleapis.com/mediapipe-models/";
@@ -12810,6 +13425,94 @@ var HackbuildAiViews = (function(exports) {
12810
13425
  runtime: "@huggingface/transformers@4.3.2",
12811
13426
  notes: ["about 3.3 GB (vendor)"]
12812
13427
  },
13428
+ {
13429
+ id: "qwen3.5-0.8b-vision",
13430
+ label: "qwen3.5 0.8b",
13431
+ speed: "fast",
13432
+ verdict: "small, reads text",
13433
+ group: "good",
13434
+ provides: ["vision.caption", "vision.ask"],
13435
+ provider: "tjs",
13436
+ source: { modelId: "onnx-community/Qwen3.5-0.8B-ONNX-OPT" },
13437
+ sizeMB: 615,
13438
+ sizeSource: "vendor",
13439
+ ladder: LADDERS.vlmGpuOnly(),
13440
+ quirks: {
13441
+ maxTokensAction: 96,
13442
+ maxImageSide: 768
13443
+ },
13444
+ licence: "Apache-2.0 (the model card's licence field)",
13445
+ commercial: true,
13446
+ place: "gpu",
13447
+ runtime: "@huggingface/transformers@4.3.2",
13448
+ notes: ["qwen3.5 takes images in every size; there is no separate qwen3.5-vl (vendor)", "transformers.js 4.0.0 or later (Qwen3_5ForConditionalGeneration)"]
13449
+ },
13450
+ {
13451
+ id: "qwen3.5-2b-vision",
13452
+ label: "qwen3.5 2b",
13453
+ speed: "steady",
13454
+ verdict: "sharper answers, heavier",
13455
+ group: "good",
13456
+ provides: ["vision.caption", "vision.ask"],
13457
+ provider: "tjs",
13458
+ source: { modelId: "onnx-community/Qwen3.5-2B-ONNX" },
13459
+ sizeMB: 1508,
13460
+ sizeSource: "vendor",
13461
+ ladder: LADDERS.vlmGpuOnly(),
13462
+ quirks: {
13463
+ maxTokensAction: 96,
13464
+ maxImageSide: 768
13465
+ },
13466
+ licence: "Apache-2.0 (the model card's licence field)",
13467
+ commercial: true,
13468
+ place: "gpu",
13469
+ runtime: "@huggingface/transformers@4.3.2",
13470
+ notes: ["transformers.js 4.0.0 or later (Qwen3_5ForConditionalGeneration)"]
13471
+ },
13472
+ {
13473
+ id: "janus-pro-1b-vision",
13474
+ label: "janus-pro 1b",
13475
+ speed: "slow",
13476
+ verdict: "sees and draws, heavy",
13477
+ group: "good",
13478
+ provides: ["vision.caption", "vision.ask"],
13479
+ provider: "tjs",
13480
+ source: { modelId: "onnx-community/Janus-Pro-1B-ONNX" },
13481
+ sizeMB: 2304,
13482
+ sizeSource: "vendor",
13483
+ ladder: [{
13484
+ device: "webgpu",
13485
+ dtype: {
13486
+ prepare_inputs_embeds: "q4",
13487
+ language_model: "q4f16",
13488
+ lm_head: "fp16",
13489
+ gen_head: "fp16",
13490
+ gen_img_embeds: "fp16",
13491
+ image_decode: "fp32"
13492
+ },
13493
+ options: {
13494
+ loader: "vision.janus",
13495
+ device: {
13496
+ prepare_inputs_embeds: "wasm",
13497
+ language_model: "webgpu",
13498
+ lm_head: "webgpu",
13499
+ gen_head: "webgpu",
13500
+ gen_img_embeds: "webgpu",
13501
+ image_decode: "webgpu"
13502
+ }
13503
+ }
13504
+ }],
13505
+ quirks: { maxTokensAction: 96 },
13506
+ licence: "DeepSeek Model License (weights; use restrictions apply), MIT (code)",
13507
+ commercial: true,
13508
+ place: "gpu",
13509
+ runtime: "@huggingface/transformers@4.3.2",
13510
+ notes: [
13511
+ "needs shader-f16 on webgpu",
13512
+ "janus-pro 7b is over 4 GB at q4: run it on your endpoint (janus-pro-7b-endpoint)",
13513
+ "the same weights draw pictures through @hackbuild/imagegen"
13514
+ ]
13515
+ },
12813
13516
  yolo10("n", 9, "instant", "nano, quick"),
12814
13517
  yolo10("s", 28, "fast", "small, sharper"),
12815
13518
  yolo10("m", 59, "steady", "medium, best boxes"),
@@ -12913,6 +13616,87 @@ var HackbuildAiViews = (function(exports) {
12913
13616
  notes: ["128 px faces; paste the result back with a feathered mask"]
12914
13617
  }
12915
13618
  ];
13619
+ ENDPOINT_RECORDS = [
13620
+ {
13621
+ id: "janus-pro-7b-endpoint",
13622
+ label: "janus-pro 7b, your endpoint",
13623
+ speed: "steady",
13624
+ verdict: "larger janus, sees only",
13625
+ group: "endpoint",
13626
+ provides: ["vision.caption", "vision.ask"],
13627
+ provider: "remote",
13628
+ source: { modelId: "janus-pro-7b" },
13629
+ sizeMB: 0,
13630
+ sizeSource: "vendor",
13631
+ ladder: [{ device: "remote" }],
13632
+ licence: "DeepSeek Model License (weights; use restrictions apply), MIT (code)",
13633
+ commercial: true,
13634
+ notes: ["llama-server -m Janus-Pro-7B.Q4_K_M.gguf --mmproj Janus-Pro-7B.mmproj-Q8_0.gguf (mradermacher/Janus-Pro-7B-GGUF, 4.22 GB plus 0.35 GB, vendor)", "image understanding only: llama.cpp drops the image generation weights; ollama has no official tag"]
13635
+ },
13636
+ {
13637
+ id: "gemma-4-e4b-endpoint",
13638
+ label: "gemma 4 e4b, your endpoint",
13639
+ speed: "steady",
13640
+ verdict: "on your machine",
13641
+ group: "endpoint",
13642
+ provides: ["vision.caption", "vision.ask"],
13643
+ provider: "remote",
13644
+ source: { modelId: "gemma4:e4b" },
13645
+ sizeMB: 0,
13646
+ sizeSource: "vendor",
13647
+ ladder: [{ device: "remote" }],
13648
+ licence: "Apache-2.0 (the model card's licence field)",
13649
+ commercial: true,
13650
+ notes: ["ollama pull gemma4:e4b; gemma4:12b, 26b and 31b take images too"]
13651
+ },
13652
+ {
13653
+ id: "qwen3.5-9b-endpoint",
13654
+ label: "qwen3.5 9b, your endpoint",
13655
+ speed: "steady",
13656
+ verdict: "on your machine",
13657
+ group: "endpoint",
13658
+ provides: ["vision.caption", "vision.ask"],
13659
+ provider: "remote",
13660
+ source: { modelId: "qwen3.5:9b" },
13661
+ sizeMB: 0,
13662
+ sizeSource: "vendor",
13663
+ ladder: [{ device: "remote" }],
13664
+ licence: "Apache-2.0 (the model card's licence field)",
13665
+ commercial: true,
13666
+ notes: ["ollama pull qwen3.5:9b; every qwen3.5 size takes images"]
13667
+ }
13668
+ ];
13669
+ }));
13670
+ // packages/vision/src/release.ts
13671
+ /**
13672
+ * Disposes every tensor among the values: a tensor itself, tensors in an
13673
+ * array, and tensors among the values of a plain record (a processor's or
13674
+ * a session's output), two levels deep. Anything else is left alone, and a
13675
+ * dispose that throws (already freed) is ignored.
13676
+ * @internal
13677
+ */
13678
+ function release(...values) {
13679
+ const seen = /* @__PURE__ */ new Set();
13680
+ const walk = (v, depth) => {
13681
+ if (!v || typeof v !== "object" || seen.has(v) || depth > 2) return;
13682
+ seen.add(v);
13683
+ if (isTensor(v)) {
13684
+ try {
13685
+ v.dispose();
13686
+ } catch {}
13687
+ return;
13688
+ }
13689
+ if (Array.isArray(v)) {
13690
+ for (const x of v) walk(x, depth + 1);
13691
+ return;
13692
+ }
13693
+ if (Object.getPrototypeOf(v) === Object.prototype) for (const x of Object.values(v)) walk(x, depth + 1);
13694
+ };
13695
+ for (const v of values) walk(v, 0);
13696
+ }
13697
+ var isTensor;
13698
+ var init_release = __esmMin((() => {
13699
+ isTensor = (v) => !!v && typeof v === "object" && typeof v.dispose === "function" && Array.isArray(v.dims);
12916
13700
  }));
12917
13701
  // packages/vision/src/segment.ts
12918
13702
  /** True when the prompt has a point or a box. */
@@ -12921,29 +13705,59 @@ var HackbuildAiViews = (function(exports) {
12921
13705
  }
12922
13706
  /** A segmenter from an encoder and a decoder, with the embedding cache on `cache`. Masks come best first, scores clamped to 0 to 1. */
12923
13707
  function promptSegmenter(o) {
12924
- const own = o.cache ?? new EmbeddingCache();
13708
+ const reading = /* @__PURE__ */ new Map();
13709
+ const evicted = /* @__PURE__ */ new Set();
13710
+ const free = (e) => {
13711
+ if (!o.release) return;
13712
+ if (reading.get(e)) evicted.add(e);
13713
+ else o.release(e);
13714
+ };
13715
+ const own = o.cache ?? new EmbeddingCache(4, free);
12925
13716
  const seg = {
12926
13717
  cache: own,
12927
13718
  async segment(image, prompt = {}, so = {}) {
12928
13719
  if (!hasPrompt(prompt)) throw new Error("a prompt needs at least one point or a box");
12929
13720
  const emb = await (so.cache ?? own).getOr(so.key ?? image, () => o.encode(image));
12930
- const masks = await o.decode(emb, prompt, image);
13721
+ reading.set(emb, (reading.get(emb) ?? 0) + 1);
13722
+ let masks;
13723
+ try {
13724
+ masks = await o.decode(emb, prompt, image);
13725
+ } finally {
13726
+ const n = (reading.get(emb) ?? 1) - 1;
13727
+ if (n > 0) reading.set(emb, n);
13728
+ else {
13729
+ reading.delete(emb);
13730
+ if (evicted.delete(emb)) o.release?.(emb);
13731
+ }
13732
+ }
12931
13733
  for (const m of masks) if (m.score !== void 0) m.score = Math.min(1, Math.max(0, m.score));
12932
13734
  return masks.sort((a, b) => (b.score ?? 0) - (a.score ?? 0));
12933
13735
  }
12934
13736
  };
12935
- if (o.dispose) seg.dispose = () => o.dispose();
13737
+ seg.dispose = () => {
13738
+ own.clear();
13739
+ return o.dispose?.();
13740
+ };
12936
13741
  return seg;
12937
13742
  }
12938
13743
  var EmbeddingCache;
12939
13744
  var init_segment = __esmMin((() => {
12940
13745
  EmbeddingCache = class {
12941
13746
  max;
13747
+ onEvict;
12942
13748
  m = /* @__PURE__ */ new Map();
12943
13749
  hits = 0;
12944
13750
  misses = 0;
12945
- constructor(max = 4) {
13751
+ /** `onEvict` gets each embedding that leaves the cache (pushed out, deleted, cleared or replaced), to free it. */
13752
+ constructor(max = 4, onEvict) {
12946
13753
  this.max = max;
13754
+ this.onEvict = onEvict;
13755
+ }
13756
+ out(p) {
13757
+ if (p && this.onEvict) {
13758
+ const f = this.onEvict;
13759
+ p.then(f, () => {});
13760
+ }
12947
13761
  }
12948
13762
  has(key) {
12949
13763
  return this.m.has(key);
@@ -12953,9 +13767,16 @@ var HackbuildAiViews = (function(exports) {
12953
13767
  return this.m.get(key);
12954
13768
  }
12955
13769
  set(key, v) {
13770
+ const p = Promise.resolve(v);
13771
+ const was = this.m.get(key);
12956
13772
  this.m.delete(key);
12957
- this.m.set(key, Promise.resolve(v));
12958
- while (this.m.size > this.max) this.m.delete(this.m.keys().next().value);
13773
+ this.m.set(key, p);
13774
+ if (was !== p) this.out(was);
13775
+ while (this.m.size > this.max) {
13776
+ const k = this.m.keys().next().value;
13777
+ this.out(this.m.get(k));
13778
+ this.m.delete(k);
13779
+ }
12959
13780
  }
12960
13781
  /** The embedding for `key`, encoding it with `make` on a miss. A failed encode is not kept. */
12961
13782
  getOr(key, make) {
@@ -12975,9 +13796,11 @@ var HackbuildAiViews = (function(exports) {
12975
13796
  return p;
12976
13797
  }
12977
13798
  delete(key) {
13799
+ this.out(this.m.get(key));
12978
13800
  return this.m.delete(key);
12979
13801
  }
12980
13802
  clear() {
13803
+ for (const p of this.m.values()) this.out(p);
12981
13804
  this.m.clear();
12982
13805
  }
12983
13806
  get size() {
@@ -12986,10 +13809,18 @@ var HackbuildAiViews = (function(exports) {
12986
13809
  };
12987
13810
  }));
12988
13811
  // packages/vision/src/loaders.ts
13812
+ /** @internal an image input as a transformers.js RawImage. */
12989
13813
  async function toRaw(tjs, img) {
12990
13814
  const R = tjs.RawImage;
12991
13815
  return R?.read ? R.read(img) : img;
12992
13816
  }
13817
+ /** @internal a RawImage resized down so its longest side is at most `side`; smaller images and no cap pass through. */
13818
+ async function capped(img, side) {
13819
+ const r = img;
13820
+ if (!side || !r.width || !r.height || !r.resize) return img;
13821
+ const k = side / Math.max(r.width, r.height);
13822
+ return k >= 1 ? img : r.resize(Math.round(r.width * k), Math.round(r.height * k));
13823
+ }
12993
13824
  /** Normalize a depth pipeline result. predicted_depth keeps the raw range; depth is the 8 bit image. */
12994
13825
  function depthFromOutput(out) {
12995
13826
  const pd = out.predicted_depth;
@@ -13050,7 +13881,7 @@ var HackbuildAiViews = (function(exports) {
13050
13881
  text: question ?? "Describe this image in one sentence."
13051
13882
  }]
13052
13883
  }], { add_generation_prompt: true });
13053
- const raw = [await toRaw(ctx.tjs, image)];
13884
+ const raw = [await capped(await toRaw(ctx.tjs, image), ctx.record.quirks?.maxImageSide)];
13054
13885
  const inputs = await (imagesFirst ? processor(raw, text) : processor(text, raw));
13055
13886
  const ids = await model.generate({
13056
13887
  ...inputs,
@@ -13060,7 +13891,11 @@ var HackbuildAiViews = (function(exports) {
13060
13891
  });
13061
13892
  const start = inputs.input_ids.dims[inputs.input_ids.dims.length - 1];
13062
13893
  const gen = ids.slice ? ids.slice(null, [start, null]) : ids;
13063
- return (processor.batch_decode(gen, { skip_special_tokens: true })[0] ?? "").trim();
13894
+ try {
13895
+ return (processor.batch_decode(gen, { skip_special_tokens: true })[0] ?? "").trim();
13896
+ } finally {
13897
+ release(inputs, ids, gen);
13898
+ }
13064
13899
  },
13065
13900
  dispose: () => model.dispose?.()
13066
13901
  };
@@ -13074,10 +13909,12 @@ var HackbuildAiViews = (function(exports) {
13074
13909
  async encode(image) {
13075
13910
  const raw = await toRaw(ctx.tjs, image);
13076
13911
  const inputs = await processor(raw);
13912
+ const emb = await model.get_image_embeddings(inputs);
13913
+ release(inputs);
13077
13914
  return {
13078
13915
  raw,
13079
13916
  inputs,
13080
- emb: await model.get_image_embeddings(inputs)
13917
+ emb
13081
13918
  };
13082
13919
  },
13083
13920
  async decode(e, prompt) {
@@ -13102,32 +13939,77 @@ var HackbuildAiViews = (function(exports) {
13102
13939
  "input_boxes"
13103
13940
  ]) if (p[k] !== void 0) feed[k] = p[k];
13104
13941
  const out = await model(feed);
13105
- const m = (await processor.post_process_masks(out.pred_masks, e.inputs.original_sizes, e.inputs.reshaped_input_sizes))[0];
13106
- const [n, h, w] = m.dims.slice(-3);
13107
- const res = [];
13108
- for (let k = 0; k < n; k++) {
13109
- const data = new Uint8Array(w * h);
13110
- for (let i = 0; i < w * h; i++) data[i] = m.data[k * w * h + i] ? 255 : 0;
13111
- res.push({
13112
- width: w,
13113
- height: h,
13114
- data,
13115
- score: out.iou_scores.data[k] ?? 0
13116
- });
13942
+ const masks = await processor.post_process_masks(out.pred_masks, e.inputs.original_sizes, e.inputs.reshaped_input_sizes);
13943
+ try {
13944
+ const m = masks[0];
13945
+ const [n, h, w] = m.dims.slice(-3);
13946
+ const res = [];
13947
+ for (let k = 0; k < n; k++) {
13948
+ const data = new Uint8Array(w * h);
13949
+ for (let i = 0; i < w * h; i++) data[i] = m.data[k * w * h + i] ? 255 : 0;
13950
+ res.push({
13951
+ width: w,
13952
+ height: h,
13953
+ data,
13954
+ score: out.iou_scores.data[k] ?? 0
13955
+ });
13956
+ }
13957
+ return res;
13958
+ } finally {
13959
+ release(p, out, masks);
13117
13960
  }
13118
- return res;
13119
13961
  },
13962
+ release: (e) => release(e.emb),
13120
13963
  dispose: () => model.dispose?.()
13121
13964
  });
13122
13965
  }
13123
13966
  var cls;
13124
13967
  var init_loaders = __esmMin((() => {
13968
+ init_release();
13125
13969
  init_segment();
13126
13970
  cls = (tjs, ...names) => {
13127
13971
  for (const n of names) if (tjs[n]) return tjs[n];
13128
13972
  throw new Error(`the transformers.js module has none of ${names.join(", ")}`);
13129
13973
  };
13130
13974
  }));
13975
+ // packages/vision/src/janus.ts
13976
+ /** One user turn with an image, in the Janus chat format. */
13977
+ function janusTurn(question, image) {
13978
+ return {
13979
+ role: "<|User|>",
13980
+ content: `<image_placeholder>\n${question}`,
13981
+ images: [image]
13982
+ };
13983
+ }
13984
+ /** The transformers.js loader for Janus records: its processor and `MultiModalityCausalLM` wrapped as a {@link Vlm}. */
13985
+ async function janusLoader(ctx) {
13986
+ const id = ctx.record.source.modelId;
13987
+ const processor = await cls(ctx.tjs, "AutoProcessor").from_pretrained(id);
13988
+ const model = await cls(ctx.tjs, "MultiModalityCausalLM").from_pretrained(id, ctx.options);
13989
+ const cap = ctx.record.quirks?.maxTokensAction ?? 96;
13990
+ return {
13991
+ async ask(image, question, o = {}) {
13992
+ const inputs = await processor([janusTurn(question ?? "Describe this image in one sentence.", await toRaw(ctx.tjs, image))]);
13993
+ const ids = await model.generate({
13994
+ ...inputs,
13995
+ max_new_tokens: o.maxTokens ?? cap,
13996
+ do_sample: false
13997
+ });
13998
+ const start = inputs.input_ids.dims[inputs.input_ids.dims.length - 1];
13999
+ const gen = ids.slice ? ids.slice(null, [start, null]) : ids;
14000
+ try {
14001
+ return (processor.batch_decode(gen, { skip_special_tokens: true })[0] ?? "").trim();
14002
+ } finally {
14003
+ release(inputs, ids, gen);
14004
+ }
14005
+ },
14006
+ dispose: () => model.dispose?.()
14007
+ };
14008
+ }
14009
+ var init_janus = __esmMin((() => {
14010
+ init_loaders();
14011
+ init_release();
14012
+ }));
13131
14013
  // packages/vision/src/yolo.ts
13132
14014
  /** The scale and padding that fit a `w` by `h` image into a `size` square (640 by default), centred. */
13133
14015
  function letterboxParams(w, h, size = 640) {
@@ -13276,14 +14158,19 @@ var HackbuildAiViews = (function(exports) {
13276
14158
  size,
13277
14159
  size
13278
14160
  ]) };
13279
- const t = (await m.session.run(feeds))[m.session.outputNames[0]];
13280
- const d = {
13281
- ...opts.scoreThreshold !== void 0 ? { scoreThreshold: opts.scoreThreshold } : {},
13282
- ...opts.maxResults !== void 0 ? { max: opts.maxResults } : {},
13283
- ...o.labels ? { labels: o.labels } : {}
13284
- };
13285
- const out = t.data;
13286
- return isEnd2End(t.dims) ? decodeYoloEnd2End(out, t.dims, lb, px, d) : decodeYolo(out, t.dims, lb, px, d);
14161
+ const res = await m.session.run(feeds);
14162
+ try {
14163
+ const t = res[m.session.outputNames[0]];
14164
+ const d = {
14165
+ ...opts.scoreThreshold !== void 0 ? { scoreThreshold: opts.scoreThreshold } : {},
14166
+ ...opts.maxResults !== void 0 ? { max: opts.maxResults } : {},
14167
+ ...o.labels ? { labels: o.labels } : {}
14168
+ };
14169
+ const out = t.data;
14170
+ return isEnd2End(t.dims) ? decodeYoloEnd2End(out, t.dims, lb, px, d) : decodeYolo(out, t.dims, lb, px, d);
14171
+ } finally {
14172
+ release(feeds, res);
14173
+ }
13287
14174
  },
13288
14175
  dispose: () => m.dispose()
13289
14176
  };
@@ -13294,6 +14181,7 @@ var HackbuildAiViews = (function(exports) {
13294
14181
  }
13295
14182
  var COCO_LABELS, DETECT_SIZES;
13296
14183
  var init_yolo = __esmMin((() => {
14184
+ init_release();
13297
14185
  COCO_LABELS = "person,bicycle,car,motorcycle,airplane,bus,train,truck,boat,traffic light,fire hydrant,stop sign,parking meter,bench,bird,cat,dog,horse,sheep,cow,elephant,bear,zebra,giraffe,backpack,umbrella,handbag,tie,suitcase,frisbee,skis,snowboard,sports ball,kite,baseball bat,baseball glove,skateboard,surfboard,tennis racket,bottle,wine glass,cup,fork,knife,spoon,bowl,banana,apple,sandwich,orange,broccoli,carrot,hot dog,pizza,donut,cake,chair,couch,potted plant,bed,dining table,toilet,tv,laptop,mouse,remote,keyboard,cell phone,microwave,oven,toaster,sink,refrigerator,book,clock,vase,scissors,teddy bear,hair drier,toothbrush".split(",");
13298
14186
  DETECT_SIZES = {
13299
14187
  n: "yolov10n",
@@ -13461,6 +14349,7 @@ var HackbuildAiViews = (function(exports) {
13461
14349
  tjs.loader("vision.caption", vlmLoader);
13462
14350
  tjs.loader("vision.ask", vlmLoader);
13463
14351
  tjs.loader("segment", samLoader);
14352
+ tjs.loader("vision.janus", janusLoader);
13464
14353
  }
13465
14354
  }
13466
14355
  async function withModel(hub, what, fn, o = {}) {
@@ -13497,8 +14386,8 @@ var HackbuildAiViews = (function(exports) {
13497
14386
  function ensureRecord(hub, id) {
13498
14387
  const have = hub.registry.get(id);
13499
14388
  if (have) return have;
13500
- const rec = PICKER_RECORDS.find((r) => r.id === id);
13501
- if (!rec) throw new Error(`${id} is neither registered nor a picker record`);
14389
+ const rec = PICKER_RECORDS.find((r) => r.id === id) ?? ENDPOINT_RECORDS.find((r) => r.id === id);
14390
+ if (!rec) throw new Error(`${id} is neither registered nor a picker or endpoint record`);
13502
14391
  hub.registry.add(rec);
13503
14392
  return rec;
13504
14393
  }
@@ -13586,14 +14475,21 @@ var HackbuildAiViews = (function(exports) {
13586
14475
  }
13587
14476
  /** Caption an image. VLM calls are serialized on one chain. */
13588
14477
  function caption(hub, image, o = {}) {
13589
- return hub.chain("vlm")(() => withModel(hub, target("vision.caption", o), (m) => m.ask(image, void 0, o.maxTokens ? { maxTokens: o.maxTokens } : {}), o));
14478
+ return hub.chain("vlm")(() => withModel(hub, target("vision.caption", o), (m) => m.ask(image, void 0, {
14479
+ ...o.maxTokens ? { maxTokens: o.maxTokens } : {},
14480
+ ...o.signal ? { signal: o.signal } : {}
14481
+ }), o));
13590
14482
  }
13591
14483
  /** Answer a question about an image with the routed vision language model. VLM calls are serialized on one chain. */
13592
14484
  function ask(hub, image, question, o = {}) {
13593
- return hub.chain("vlm")(() => withModel(hub, target("vision.ask", o), (m) => m.ask(image, question, o.maxTokens ? { maxTokens: o.maxTokens } : {}), o));
14485
+ return hub.chain("vlm")(() => withModel(hub, target("vision.ask", o), (m) => m.ask(image, question, {
14486
+ ...o.maxTokens ? { maxTokens: o.maxTokens } : {},
14487
+ ...o.signal ? { signal: o.signal } : {}
14488
+ }), o));
13594
14489
  }
13595
14490
  var target;
13596
14491
  var init_api = __esmMin((() => {
14492
+ init_janus();
13597
14493
  init_loaders();
13598
14494
  init_fastsam();
13599
14495
  init_records();
@@ -13601,6 +14497,98 @@ var HackbuildAiViews = (function(exports) {
13601
14497
  init_yolo();
13602
14498
  target = (cap, o) => o.model ? { id: o.model } : cap;
13603
14499
  }));
14500
+ // packages/vision/src/endpoint.ts
14501
+ function base64(bytes) {
14502
+ let s = "";
14503
+ for (let i = 0; i < bytes.length; i += 32768) s += String.fromCharCode(...bytes.subarray(i, i + 32768));
14504
+ return btoa(s);
14505
+ }
14506
+ /**
14507
+ * An image input as a URL an endpoint can read: a string passes through
14508
+ * (data or http URL), a Blob becomes a data URL, and pixels, canvases,
14509
+ * video frames and bitmaps are drawn and encoded as JPEG.
14510
+ */
14511
+ async function imageUrl(image) {
14512
+ if (typeof image === "string") return image;
14513
+ if (typeof Blob !== "undefined" && image instanceof Blob) return `data:${image.type || "image/png"};base64,${base64(new Uint8Array(await image.arrayBuffer()))}`;
14514
+ const src = image;
14515
+ const w = src.videoWidth || src.displayWidth || src.width || 0;
14516
+ const h = src.videoHeight || src.displayHeight || src.height || 0;
14517
+ if (!w || !h || typeof OffscreenCanvas === "undefined") throw new Error("vision endpoint: pass a url, a blob, pixels or something a canvas can draw");
14518
+ const c = new OffscreenCanvas(w, h);
14519
+ const g = c.getContext("2d");
14520
+ if (isPixels(image)) g.putImageData(new ImageData(new Uint8ClampedArray(image.data), w, h), 0, 0);
14521
+ else g.drawImage(image, 0, 0, w, h);
14522
+ return imageUrl(await c.convertToBlob({
14523
+ type: "image/jpeg",
14524
+ quality: .85
14525
+ }));
14526
+ }
14527
+ /** The chat completions body for one image and one question. */
14528
+ function endpointBody(model, url, question, maxTokens) {
14529
+ return {
14530
+ model,
14531
+ stream: false,
14532
+ max_tokens: maxTokens,
14533
+ messages: [{
14534
+ role: "user",
14535
+ content: [{
14536
+ type: "text",
14537
+ text: question
14538
+ }, {
14539
+ type: "image_url",
14540
+ image_url: { url }
14541
+ }]
14542
+ }]
14543
+ };
14544
+ }
14545
+ /** A {@link Vlm} that asks the endpoint's model about each image. */
14546
+ function endpointVlm(o) {
14547
+ const f = o.fetch ?? globalThis.fetch.bind(globalThis);
14548
+ const url = o.base.replace(/\/+$/, "") + "/chat/completions";
14549
+ return { async ask(image, question, opts = {}) {
14550
+ const body = endpointBody(o.model, await (o.toUrl ?? imageUrl)(image), question ?? "Describe this image in one sentence.", opts.maxTokens ?? o.maxTokens ?? 128);
14551
+ const headers = {
14552
+ "content-type": "application/json",
14553
+ ...o.headers
14554
+ };
14555
+ if (o.apiKey) headers.authorization = `Bearer ${o.apiKey}`;
14556
+ const res = await f(url, {
14557
+ method: "POST",
14558
+ headers,
14559
+ body: JSON.stringify(body),
14560
+ ...opts.signal ? { signal: opts.signal } : {}
14561
+ });
14562
+ if (!res.ok) {
14563
+ const text = (await res.text()).slice(0, 200);
14564
+ throw new Error(`vision endpoint ${res.status}: ${o.apiKey ? text.split(o.apiKey).join("[key]") : text}`);
14565
+ }
14566
+ const c = (await res.json()).choices?.[0]?.message?.content;
14567
+ return (typeof c === "string" ? c : Array.isArray(c) ? c.map((p) => p.text ?? "").join("") : "").trim();
14568
+ } };
14569
+ }
14570
+ /**
14571
+ * The hub factory for remote vision records (`provider: "remote"`): each
14572
+ * record's `source.modelId` names the endpoint's model. A hub has one
14573
+ * factory per provider, so a hub that also runs remote chat passes that
14574
+ * factory as `others`, and records that are not vision go to it. Register
14575
+ * with `hub.provide("remote", endpointVisionProvider({ base, others }))`.
14576
+ */
14577
+ function endpointVisionProvider(o) {
14578
+ const { others, ...vlm } = o;
14579
+ return async (ctx) => {
14580
+ if (ctx.record.provides.some((c) => c === "vision.ask" || c === "vision.caption")) return endpointVlm({
14581
+ ...vlm,
14582
+ model: ctx.record.source.modelId ?? ctx.record.id
14583
+ });
14584
+ if (others) return others(ctx);
14585
+ throw new Error(`${ctx.record.id}: the vision endpoint runs vision records; pass others for the rest`);
14586
+ };
14587
+ }
14588
+ var isPixels;
14589
+ var init_endpoint = __esmMin((() => {
14590
+ isPixels = (x) => !!x && typeof x === "object" && typeof x.width === "number" && typeof x.height === "number" && !!x.data;
14591
+ }));
13604
14592
  // packages/vision/src/mediapipe.ts
13605
14593
  /** The URL @mediapipe/tasks-vision is imported from, on jsDelivr. */
13606
14594
  function tasksVisionUrls(version = TASKS_VISION) {
@@ -15174,6 +16162,7 @@ self.onmessage = async (ev) => {
15174
16162
  DEFAULT_REACTIONS: () => DEFAULT_REACTIONS,
15175
16163
  DEPTH_WORKER_SOURCE: () => DEPTH_WORKER_SOURCE,
15176
16164
  DETECT_SIZES: () => DETECT_SIZES,
16165
+ ENDPOINT_RECORDS: () => ENDPOINT_RECORDS,
15177
16166
  EmbeddingCache: () => EmbeddingCache,
15178
16167
  LOOK_PATTERN: () => LOOK_PATTERN,
15179
16168
  MP_MODELS: () => MP_MODELS,
@@ -15209,6 +16198,9 @@ self.onmessage = async (ev) => {
15209
16198
  edgeMask: () => edgeMask,
15210
16199
  emptyMask: () => emptyMask,
15211
16200
  encodePng: () => encodePng,
16201
+ endpointBody: () => endpointBody,
16202
+ endpointVisionProvider: () => endpointVisionProvider,
16203
+ endpointVlm: () => endpointVlm,
15212
16204
  ensureRecord: () => ensureRecord,
15213
16205
  exportInstances: () => exportInstances,
15214
16206
  faceApiProvider: () => faceApiProvider,
@@ -15219,9 +16211,12 @@ self.onmessage = async (ev) => {
15219
16211
  fixedVlm: () => fixedVlm,
15220
16212
  gazeTarget: () => gazeTarget,
15221
16213
  hasPrompt: () => hasPrompt,
16214
+ imageUrl: () => imageUrl,
15222
16215
  instanceAt: () => instanceAt,
15223
16216
  iou: () => iou,
15224
16217
  isEnd2End: () => isEnd2End,
16218
+ janusLoader: () => janusLoader,
16219
+ janusTurn: () => janusTurn,
15225
16220
  landmarkChain: () => landmarkChain,
15226
16221
  landmarks: () => landmarks,
15227
16222
  letterboxParams: () => letterboxParams,
@@ -15275,6 +16270,8 @@ self.onmessage = async (ev) => {
15275
16270
  init_records();
15276
16271
  init_api();
15277
16272
  init_loaders();
16273
+ init_janus();
16274
+ init_endpoint();
15278
16275
  init_mediapipe();
15279
16276
  init_faceapi();
15280
16277
  init_yolo();
@@ -18523,7 +19520,7 @@ self.onmessage = async (ev) => {
18523
19520
  init_src$11();
18524
19521
  /** Pinned CDN modules jobLoader imports at load time. */
18525
19522
  const RUNTIME_URLS = {
18526
- webllm: ["https://esm.run/@mlc-ai/web-llm@0.2.84", "https://cdn.jsdelivr.net/npm/@mlc-ai/web-llm@0.2.84/+esm"],
19523
+ webllm: ["https://esm.run/@mlc-ai/web-llm@0.2.89", "https://cdn.jsdelivr.net/npm/@mlc-ai/web-llm@0.2.89/+esm"],
18527
19524
  bellows: ["https://cdn.jsdelivr.net/npm/bellows-voice@0.8.0/engine/+esm"],
18528
19525
  kokoro: ["https://cdn.jsdelivr.net/npm/kokoro-js@1.2.1/+esm"]
18529
19526
  };
@@ -18585,6 +19582,8 @@ self.onmessage = async (ev) => {
18585
19582
  tjs.loader("vision.caption", vision.vlmLoader);
18586
19583
  tjs.loader("vision.ask", vision.vlmLoader);
18587
19584
  tjs.loader("segment", vision.samLoader);
19585
+ tjs.loader("vision.janus", vision.janusLoader);
19586
+ tjs.loader("imagegen.janus", async (ctx) => (await Promise.resolve().then(() => (init_src$6(), src_exports$5))).janusImageLoader(ctx));
18588
19587
  tjs.loader("chat", async (ctx) => {
18589
19588
  const { createEngine } = await Promise.resolve().then(() => (init_src(), src_exports));
18590
19589
  const generator = await ctx.tjs.pipeline("text-generation", ctx.record.source.modelId ?? ctx.record.id, ctx.options);
@@ -18639,7 +19638,8 @@ self.onmessage = async (ev) => {
18639
19638
  async function webllmFactory(ctx, m) {
18640
19639
  const w = await Promise.resolve().then(() => (init_webllm(), webllm_exports));
18641
19640
  const mod = await (m.webllm ?? (() => importEsm(RUNTIME_URLS.webllm)))();
18642
- const id = ctx.record.source.modelId ?? ctx.record.id;
19641
+ const rungId = ctx.rung.options?.modelId;
19642
+ const id = typeof rungId === "string" ? rungId : ctx.record.source.modelId ?? ctx.record.id;
18643
19643
  return w.loadWebLLM({
18644
19644
  module: mod,
18645
19645
  modelId: id,
@@ -18868,7 +19868,7 @@ self.onmessage = async (ev) => {
18868
19868
  }
18869
19869
  case "image": {
18870
19870
  const gen = await (await Promise.resolve().then(() => (init_src$6(), src_exports$5))).loadImagegen(hub, { id: rec.id }, { ...ctx.signal ? { signal: ctx.signal } : {} });
18871
- const tokenize = await clipTokenizer(rt, gen.form.tokenizer);
19871
+ const tokenize = gen.form.pipeline === "janus" ? async () => /* @__PURE__ */ new Int32Array(0) : await clipTokenizer(rt, gen.form.tokenizer);
18872
19872
  return Object.assign(gen, {
18873
19873
  tokenize,
18874
19874
  make: (o) => gen.generate(tokenize, o)