mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-09-21 03:01:27 -03:00
feat(backend): CivitAI download support for other model types with subtype routing
This commit is contained in:
@@ -126,6 +126,20 @@ CIVITAI_TYPE_TO_OTHER_SUB_TYPE = {
|
||||
"controlnet": "controlnet",
|
||||
}
|
||||
|
||||
# CivitAI ModelFile.type values -> internal sub_type for the "other" model
|
||||
# page. Used for download routing only, and strictly as an explicit user file
|
||||
# pick or a fallback when model.type maps to nothing — checkpoint models
|
||||
# routinely bundle VAE/Text Encoder component files, so file types must never
|
||||
# override a mapped model.type.
|
||||
CIVITAI_FILE_TYPE_TO_OTHER_SUB_TYPE = {
|
||||
"VAE": "vae",
|
||||
"Upscaler": "upscaler",
|
||||
"Text Encoder": "text_encoder",
|
||||
"Vision Encoder": "clip_vision",
|
||||
"CLIPVision": "clip_vision",
|
||||
"ControlNet": "controlnet",
|
||||
}
|
||||
|
||||
# Backward compatibility alias
|
||||
VALID_LORA_TYPES = VALID_LORA_SUB_TYPES
|
||||
|
||||
@@ -134,6 +148,7 @@ CIVITAI_USER_MODEL_TYPES = [
|
||||
*VALID_LORA_TYPES,
|
||||
"textualinversion",
|
||||
"checkpoint",
|
||||
*sorted(VALID_OTHER_CIVITAI_TYPES),
|
||||
]
|
||||
|
||||
# Default chunk size in megabytes used for hashing large files.
|
||||
|
||||
@@ -420,6 +420,10 @@ class DownloadManager:
|
||||
embedding_scanner = await ServiceRegistry.get_embedding_scanner()
|
||||
scanners.append(("embedding", embedding_scanner))
|
||||
|
||||
if "other" in model_types:
|
||||
other_scanner = await ServiceRegistry.get_other_scanner()
|
||||
scanners.append(("other", other_scanner))
|
||||
|
||||
# Load progress file to check processed models (async to avoid blocking)
|
||||
settings_manager = get_settings_manager()
|
||||
active_library = settings_manager.get_active_library_name()
|
||||
@@ -600,6 +604,10 @@ class DownloadManager:
|
||||
embedding_scanner = await ServiceRegistry.get_embedding_scanner()
|
||||
scanners.append(("embedding", embedding_scanner))
|
||||
|
||||
if "other" in model_types:
|
||||
other_scanner = await ServiceRegistry.get_other_scanner()
|
||||
scanners.append(("other", other_scanner))
|
||||
|
||||
# Get all models
|
||||
all_models = []
|
||||
for scanner_type, scanner in scanners:
|
||||
@@ -1098,6 +1106,10 @@ class DownloadManager:
|
||||
embedding_scanner = await ServiceRegistry.get_embedding_scanner()
|
||||
scanners.append(("embedding", embedding_scanner))
|
||||
|
||||
if "other" in model_types:
|
||||
other_scanner = await ServiceRegistry.get_other_scanner()
|
||||
scanners.append(("other", other_scanner))
|
||||
|
||||
# Find the specified models
|
||||
models_to_process = []
|
||||
for scanner_type, scanner in scanners:
|
||||
|
||||
+2
-1
@@ -340,7 +340,8 @@ class OtherModelMetadata(BaseModelMetadata):
|
||||
sha256_value = (file_info.get("hashes") or {}).get("SHA256", "").lower()
|
||||
# Map the CivitAI model type onto our sub_types; unknown types keep the
|
||||
# placeholder until the scanner re-derives sub_type from the location.
|
||||
civitai_type = str(version_info.get("type", "") or "").lower()
|
||||
# The type lives at version["model"]["type"], not version["type"].
|
||||
civitai_type = str((version_info.get("model") or {}).get("type", "") or "").lower()
|
||||
sub_type = CIVITAI_TYPE_TO_OTHER_SUB_TYPE.get(civitai_type, "vae")
|
||||
|
||||
# Extract tags and description if available
|
||||
|
||||
Reference in New Issue
Block a user