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