125 lines
4.4 KiB
JavaScript
125 lines
4.4 KiB
JavaScript
// Model constants — shared between model-settings-bridge.js and Svelte components.
|
|
// Architecture and family definitions for classification fields.
|
|
// Precision extraction and file resolution for multi-variant catalog entries.
|
|
|
|
const PRIMARY_FOLDERS = new Set(["diffusion_models", "unet", "checkpoints"]);
|
|
|
|
// A precision's tier, so a companion file (text encoder, VAE) pairs with the
|
|
// chosen primary precision even when their labels differ — a diffusion
|
|
// "fp8_scaled" alongside a text-encoder "fp8", or a GGUF-quant primary
|
|
// (Q5_K_M) with an fp8/fp16 text encoder. High-precision primaries pull the
|
|
// high-precision companion; everything else (fp8*, fp4, GGUF quants) pulls the
|
|
// lighter one.
|
|
function precisionTier(precision) {
|
|
return /fp16|bf16|fp32/i.test(precision || "") ? "high" : "low";
|
|
}
|
|
|
|
export function extractPrecisions(files) {
|
|
// Only the primary diffusion/unet/checkpoint entry's variants define the
|
|
// user-selectable precisions. Companion files carry their own variant labels
|
|
// (umt5 "fp8"/"fp16") that must not appear as standalone choices — selecting
|
|
// one would resolve no diffusion file. They're paired to the chosen primary
|
|
// precision by resolveFilesForPrecision instead.
|
|
const primary = files.find(f => f.variants && PRIMARY_FOLDERS.has(f.folder))
|
|
|| files.find(f => f.variants);
|
|
const precisions = [];
|
|
for (const v of primary?.variants || []) {
|
|
if (!precisions.includes(v.precision)) precisions.push(v.precision);
|
|
}
|
|
return precisions;
|
|
}
|
|
|
|
export function resolveFilesForPrecision(files, precision) {
|
|
const tier = precisionTier(precision);
|
|
return files.map(f => {
|
|
if (!f.variants) return f;
|
|
// Exact precision wins; otherwise pair by tier so a companion file whose
|
|
// labels don't match the primary still resolves to a compatible variant
|
|
// rather than being dropped from the download set.
|
|
const match = f.variants.find(v => v.precision === precision)
|
|
|| f.variants.find(v => precisionTier(v.precision) === tier)
|
|
|| f.variants[0];
|
|
return match ? { label: f.label, folder: f.folder, filename: match.filename, size_bytes: match.size_bytes, source: match.source } : null;
|
|
}).filter(Boolean);
|
|
}
|
|
|
|
export const ARCHITECTURES = [
|
|
{ id: "sdxl", label: "SDXL" },
|
|
{ id: "sd15", label: "SD 1.5" },
|
|
{ id: "flux", label: "Flux" },
|
|
{ id: "flux2", label: "Flux 2" },
|
|
{ id: "sd3", label: "SD3" },
|
|
{ id: "zimage", label: "Z-Image" },
|
|
{ id: "qwen_image", label: "Qwen Image" },
|
|
{ id: "qwen_edit", label: "Qwen Edit" },
|
|
{ id: "wan22", label: "Wan 2.2" },
|
|
{ id: "ltx", label: "LTX Video" },
|
|
{ id: "hunyuan_video", label: "HunyuanVideo" },
|
|
{ id: "hidream", label: "HiDream" },
|
|
{ id: "ernie", label: "ERNIE Image" },
|
|
{ id: "ideogram", label: "Ideogram" },
|
|
];
|
|
|
|
export const FAMILIES = {
|
|
sdxl: [
|
|
{ id: "base_sdxl", label: "Base SDXL" },
|
|
{ id: "pony", label: "Pony" },
|
|
{ id: "illustrious", label: "Illustrious" },
|
|
{ id: "noobai", label: "NoobAI" },
|
|
],
|
|
sd15: [
|
|
{ id: "base_sd15", label: "Base SD 1.5" },
|
|
{ id: "nai", label: "NAI" },
|
|
],
|
|
flux: [
|
|
{ id: "flux_dev", label: "Flux Dev" },
|
|
{ id: "flux_schnell", label: "Flux Schnell" },
|
|
{ id: "flux_fill", label: "Flux Fill" },
|
|
{ id: "flux_kontext", label: "Flux Kontext" },
|
|
],
|
|
flux2: [
|
|
{ id: "flux2", label: "Flux 2" },
|
|
{ id: "flux2_gguf", label: "Flux 2 GGUF" },
|
|
{ id: "flux2_klein", label: "Flux 2 Klein" },
|
|
],
|
|
sd3: [
|
|
{ id: "sd3", label: "SD3" },
|
|
{ id: "sd3.5", label: "SD 3.5" },
|
|
],
|
|
zimage: [
|
|
{ id: "zimage_base", label: "Z-Image Base" },
|
|
{ id: "zimage_turbo", label: "Z-Image Turbo" },
|
|
],
|
|
qwen_image: [
|
|
{ id: "qwen_image", label: "Qwen Image" },
|
|
],
|
|
qwen_edit: [
|
|
{ id: "qwen_edit", label: "Qwen Edit" },
|
|
{ id: "qwen_aio", label: "Qwen AIO" },
|
|
],
|
|
wan22: [
|
|
{ id: "wan22_i2v", label: "Wan I2V 14B" },
|
|
{ id: "wan22_i2v_gguf", label: "Wan I2V 14B (GGUF)" },
|
|
{ id: "wan22_t2v", label: "Wan T2V 14B" },
|
|
{ id: "wan22_t2v_gguf", label: "Wan T2V 14B (GGUF)" },
|
|
{ id: "wan22_5b", label: "Wan TI2V 5B" },
|
|
{ id: "wan22_5b_gguf", label: "Wan TI2V 5B (GGUF)" },
|
|
],
|
|
ltx: [
|
|
{ id: "ltx23", label: "LTX 2.3" },
|
|
],
|
|
hunyuan_video: [
|
|
{ id: "hunyuan_video_15", label: "HunyuanVideo 1.5" },
|
|
],
|
|
hidream: [
|
|
{ id: "hidream", label: "HiDream-I1" },
|
|
],
|
|
ernie: [
|
|
{ id: "ernie_base", label: "ERNIE Image" },
|
|
{ id: "ernie_turbo", label: "ERNIE Image Turbo" },
|
|
],
|
|
ideogram: [
|
|
{ id: "ideogram4", label: "Ideogram 4" },
|
|
],
|
|
};
|