From e4120bd4d6b6412007278018d01db5b9dffc27e0 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Tue, 7 Oct 2025 10:57:17 -0400 Subject: [PATCH] detect sdnq saved model Signed-off-by: Vladimir Mandic --- modules/sd_detect.py | 5 +++++ modules/sd_models.py | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/modules/sd_detect.py b/modules/sd_detect.py index 0cd3cdb86..059b081a4 100644 --- a/modules/sd_detect.py +++ b/modules/sd_detect.py @@ -124,6 +124,8 @@ def guess_by_name(fn, current_guess): def guess_by_diffusers(fn, current_guess): exclude_by_name = ['ostris/Flex.2-preview'] # pipeline may be misleading + if not os.path.isdir(fn): + return current_guess, None index = os.path.join(fn, 'model_index.json') if os.path.exists(index) and os.path.isfile(index): index = shared.readfile(index, silent=True) @@ -136,9 +138,12 @@ def guess_by_diffusers(fn, current_guess): if pipeline is None: pipeline = cls if callable(pipeline): + is_quant = any(f for f in os.listdir(fn) if f.endswith('quantization_config.json')) pipelines = shared_items.get_pipelines() for k, v in pipelines.items(): if v is not None and v.__name__ == pipeline.__name__: + if is_quant: + k = f'{k} SDNQ' return k, v return current_guess, None diff --git a/modules/sd_models.py b/modules/sd_models.py index 426a7ca3d..449e26772 100644 --- a/modules/sd_models.py +++ b/modules/sd_models.py @@ -541,6 +541,11 @@ def load_diffuser_file(model_type, pipeline, checkpoint_info, diffusers_load_con return sd_model +def load_sdnq_model(checkpoint_info, pipeline, diffusers_load_config, op): + shared.log.error(f'Load {op}: model="{checkpoint_info.name}" cls={pipeline.__name__} args={diffusers_load_config} SDNQ pre-quant not supported') + return None + + def set_overrides(sd_model, checkpoint_info): checkpoint_info_name = checkpoint_info.name.lower() if 'bigaspv25' in checkpoint_info_name or ('flow' in checkpoint_info_name and 'flower' not in checkpoint_info_name): @@ -657,6 +662,12 @@ def load_diffuser(checkpoint_info=None, op='model', revision=None): # pylint: di shared.log.error(f'Load {op}: type="{model_type}" pipeline="{pipeline}" not loaded') return + # load sdnq-prequantized model + if sd_model is None: + if model_type.endswith('SDNQ'): + allow_post_quant = False + sd_model = load_sdnq_model(checkpoint_info, pipeline, 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':