mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-26 07:35:44 -03:00
fix(routes): enhance model processing to include checks for missing tags, description, and creator
This commit is contained in:
@@ -611,10 +611,19 @@ class BaseModelRoutes(ABC):
|
|||||||
success = 0
|
success = 0
|
||||||
needs_resort = False
|
needs_resort = False
|
||||||
|
|
||||||
# Prepare models to process, only those without CivitAI data
|
# Prepare models to process, only those without CivitAI data or missing tags, description, or creator
|
||||||
to_process = [
|
to_process = [
|
||||||
model for model in cache.raw_data
|
model for model in cache.raw_data
|
||||||
if model.get('sha256') and (not model.get('civitai') or 'id' not in model.get('civitai'))
|
if (
|
||||||
|
model.get('sha256')
|
||||||
|
and (
|
||||||
|
not model.get('civitai')
|
||||||
|
or not model['civitai'].get('id')
|
||||||
|
or not model.get('tags')
|
||||||
|
or not model.get('modelDescription')
|
||||||
|
or not (model.get('civitai') and model['civitai'].get('creator'))
|
||||||
|
)
|
||||||
|
)
|
||||||
]
|
]
|
||||||
total_to_process = len(to_process)
|
total_to_process = len(to_process)
|
||||||
|
|
||||||
|
|||||||
@@ -83,38 +83,27 @@ class ModelRouteUtils:
|
|||||||
local_metadata['civitai'] = merged_civitai
|
local_metadata['civitai'] = merged_civitai
|
||||||
local_metadata['from_civitai'] = True
|
local_metadata['from_civitai'] = True
|
||||||
|
|
||||||
# Update model name if available
|
# Update model-related metadata from civitai_metadata.model
|
||||||
if 'model' in civitai_metadata:
|
if 'model' in civitai_metadata and civitai_metadata['model']:
|
||||||
if civitai_metadata.get('model', {}).get('name'):
|
model_data = civitai_metadata['model']
|
||||||
local_metadata['model_name'] = civitai_metadata['model']['name']
|
|
||||||
|
|
||||||
# Extract model metadata directly from civitai_metadata if available
|
# Update model name if available and not already set
|
||||||
model_metadata = None
|
if model_data.get('name'):
|
||||||
|
local_metadata['model_name'] = model_data['name']
|
||||||
|
|
||||||
if 'model' in civitai_metadata and civitai_metadata.get('model'):
|
# Update modelDescription if missing or empty in local_metadata
|
||||||
# Data is already available in the response from get_model_version
|
if not local_metadata.get('modelDescription') and model_data.get('description'):
|
||||||
model_metadata = {
|
local_metadata['modelDescription'] = model_data['description']
|
||||||
'description': civitai_metadata.get('model', {}).get('description', ''),
|
|
||||||
'tags': civitai_metadata.get('model', {}).get('tags', []),
|
|
||||||
'creator': civitai_metadata.get('creator', {})
|
|
||||||
}
|
|
||||||
|
|
||||||
# If we have modelId and don't have enough metadata, fetch additional data
|
# Update tags if missing or empty in local_metadata
|
||||||
if not model_metadata or not model_metadata.get('description'):
|
if not local_metadata.get('tags') and model_data.get('tags'):
|
||||||
model_id = civitai_metadata.get('modelId')
|
local_metadata['tags'] = model_data['tags']
|
||||||
if model_id and metadata_provider:
|
|
||||||
fetched_metadata, _ = await metadata_provider.get_model_metadata(str(model_id))
|
|
||||||
if fetched_metadata:
|
|
||||||
model_metadata = fetched_metadata
|
|
||||||
|
|
||||||
# Update local metadata with the model information
|
# Update creator in civitai metadata if missing
|
||||||
if model_metadata:
|
if model_data.get('creator') and not local_metadata.get('civitai', {}).get('creator'):
|
||||||
local_metadata['modelDescription'] = model_metadata.get('description', '')
|
if 'civitai' not in local_metadata:
|
||||||
# Only set tags if local_metadata['tags'] is empty
|
local_metadata['civitai'] = {}
|
||||||
if not local_metadata.get('tags'):
|
local_metadata['civitai']['creator'] = model_data['creator']
|
||||||
local_metadata['tags'] = model_metadata.get('tags', [])
|
|
||||||
if 'creator' in model_metadata and model_metadata['creator']:
|
|
||||||
local_metadata['civitai']['creator'] = model_metadata['creator']
|
|
||||||
|
|
||||||
# Update base model
|
# Update base model
|
||||||
local_metadata['base_model'] = determine_base_model(civitai_metadata.get('baseModel'))
|
local_metadata['base_model'] = determine_base_model(civitai_metadata.get('baseModel'))
|
||||||
|
|||||||
Reference in New Issue
Block a user