reference load cleanup

Signed-off-by: vladmandic <mandic00@live.com>
This commit is contained in:
vladmandic
2025-10-25 23:25:10 -04:00
parent cffca11d5b
commit 512036d291
6 changed files with 28 additions and 18 deletions
+10 -6
View File
@@ -425,6 +425,10 @@ def load_diffuser_folder(model_type, pipeline, checkpoint_info, diffusers_load_c
try: #0 - using detected model type and pipeline
if (model_type is not None) and (pipeline is not None):
if ('sdnq' in model_type.lower()) or ('sdnq' in checkpoint_info.path.lower()):
from modules import sdnq # pylint: disable=unused-import # register to diffusers and transformers
global allow_post_quant # pylint: disable=global-statement
allow_post_quant = False
sd_model = pipeline.from_pretrained(checkpoint_info.path, cache_dir=shared.opts.diffusers_dir, **diffusers_load_config)
sd_model.model_type = sd_model.__class__.__name__
except Exception as e:
@@ -466,7 +470,7 @@ def load_diffuser_folder(model_type, pipeline, checkpoint_info, diffusers_load_c
try: # 3 - try basic pipeline just in case
if err2 is not None:
sd_model = diffusers.StableDiffusionPipeline.from_pretrained(checkpoint_info.path, cache_dir=shared.opts.diffusers_dir, **diffusers_load_config)
sd_model = diffusers.StableDiffusionXLPipeline.from_pretrained(checkpoint_info.path, cache_dir=shared.opts.diffusers_dir, **diffusers_load_config)
sd_model.model_type = sd_model.__class__.__name__
except Exception as e:
err3 = e # ignore last error
@@ -712,16 +716,16 @@ def load_diffuser(checkpoint_info=None, op='model', revision=None): # pylint: di
allow_post_quant = False
model_type = model_type.replace(' SDNQ', '')
# load from hf folder-style
if sd_model is None:
if os.path.isdir(checkpoint_info.path) or checkpoint_info.type == 'huggingface' or checkpoint_info.type == 'transformer':
sd_model = load_diffuser_folder(model_type, pipeline, checkpoint_info, diffusers_load_config, op)
# load from single-file
if sd_model is None:
if os.path.isfile(checkpoint_info.path) and checkpoint_info.path.lower().endswith('.safetensors'):
sd_model = load_diffuser_file(model_type, pipeline, checkpoint_info, diffusers_load_config, op)
# load from hf folder-style
if sd_model is None:
if os.path.isdir(checkpoint_info.path) or (checkpoint_info.type == 'huggingface') or (checkpoint_info.type == 'transformer') or (checkpoint_info.type == 'reference'):
sd_model = load_diffuser_folder(model_type, pipeline, checkpoint_info, diffusers_load_config, op)
if sd_model is None:
shared.log.error(f'Load {op}: name="{checkpoint_info.name if checkpoint_info is not None else None}" not loaded')
return