Unify metadata workflow cache and category handling
This commit is contained in:
@@ -16,6 +16,7 @@ export const CATEGORY_ALIASES = Object.freeze(
|
||||
"background_removal_model": "background_removal",
|
||||
"checkpoint": "checkpoints",
|
||||
"checkpoints": "checkpoints",
|
||||
"ckpt": "checkpoints",
|
||||
"clip": "text_encoders",
|
||||
"clip_gguf": "text_encoders",
|
||||
"clip_vision": "clip_vision",
|
||||
@@ -67,8 +68,10 @@ export const CATEGORY_ALIASES = Object.freeze(
|
||||
"ultralytics_segm": "ultralytics",
|
||||
"unet": "diffusion_models",
|
||||
"unet_gguf": "diffusion_models",
|
||||
"upscale": "upscale_models",
|
||||
"upscale_model": "upscale_models",
|
||||
"upscale_models": "upscale_models",
|
||||
"upscalemodel": "upscale_models",
|
||||
"upscaler": "upscale_models",
|
||||
"vae": "vae",
|
||||
"vae_approx": "vae_approx",
|
||||
|
||||
@@ -1,5 +1,22 @@
|
||||
import { CATEGORY_ALIASES, normalizeCategoryToken } from './category_aliases.generated.js';
|
||||
|
||||
export function normalizeCategoryValue(
|
||||
category = '',
|
||||
{
|
||||
aliases = CATEGORY_ALIASES,
|
||||
defaultValue = '',
|
||||
emptyValues = ['unknown', 'none', 'null'],
|
||||
} = {},
|
||||
) {
|
||||
const token = normalizeCategoryToken(category);
|
||||
const categoryAliases = aliases && typeof aliases === 'object'
|
||||
? aliases
|
||||
: CATEGORY_ALIASES;
|
||||
const emptyTokens = new Set(emptyValues);
|
||||
if (!token || emptyTokens.has(token)) return defaultValue;
|
||||
return categoryAliases[token] || token;
|
||||
}
|
||||
|
||||
export function normalizeDownloadCategoryValue(
|
||||
category = '',
|
||||
aliases = CATEGORY_ALIASES,
|
||||
|
||||
Reference in New Issue
Block a user