From 3881f51fde2ada5727c1cfdbfe228b4282971219 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Tue, 2 Jan 2024 10:30:38 -0500 Subject: [PATCH] fix img2img sampler selection --- CHANGELOG.md | 1 + extensions-builtin/sd-webui-controlnet | 2 +- modules/processing.py | 10 ++++++---- modules/sd_samplers.py | 3 ++- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e008d98fc..1b86b81e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,7 @@ And it also includes fixes for all reported issues so far - ipadapter: fix fallback of cross-attention on unload - python: fix python 3.9 compatibility - img2img: clip and blip interrogate + - img2img: sampler selection offset - sampler: guard against invalid sampler index - config: reset default cfg scale to 6.0 - processing: correct display metadata diff --git a/extensions-builtin/sd-webui-controlnet b/extensions-builtin/sd-webui-controlnet index 9b6a2a0ba..4cf15d1c9 160000 --- a/extensions-builtin/sd-webui-controlnet +++ b/extensions-builtin/sd-webui-controlnet @@ -1 +1 @@ -Subproject commit 9b6a2a0ba8cecf06ffde471f93fa40595f3398da +Subproject commit 4cf15d1c9c565b8d0c5f782a89c5a6286dc6e6ff diff --git a/modules/processing.py b/modules/processing.py index 8dcef9b4f..5eebab67f 100644 --- a/modules/processing.py +++ b/modules/processing.py @@ -121,12 +121,14 @@ def txt2img_image_conditioning(sd_model, x, width, height): def get_sampler_name(sampler_index: int, img: bool = False) -> str: - samplers = modules.sd_samplers.samplers if not img else modules.sd_samplers.samplers_for_img2img - if len(samplers) > sampler_index: - sampler_name = samplers[sampler_index].name + if len(modules.sd_samplers.samplers) > sampler_index: + sampler_name = modules.sd_samplers.samplers[sampler_index].name else: sampler_name = "UniPC" - shared.log.warning(f'Sampler not found: index={sampler_index} available={[s.name for s in samplers]} fallback={sampler_name}') + shared.log.warning(f'Sampler not found: index={sampler_index} available={[s.name for s in modules.sd_samplers.samplers]} fallback={sampler_name}') + if img and sampler_name == "PLMS": + sampler_name = "UniPC" + shared.log.warning(f'Sampler not compatible: name=PLMS fallback={sampler_name}') return sampler_name diff --git a/modules/sd_samplers.py b/modules/sd_samplers.py index 5b710f449..891d83eea 100644 --- a/modules/sd_samplers.py +++ b/modules/sd_samplers.py @@ -74,7 +74,8 @@ def set_samplers(): global samplers # pylint: disable=global-statement global samplers_for_img2img # pylint: disable=global-statement samplers = visible_sampler_names() - samplers_for_img2img = [x for x in samplers if x.name != "PLMS"] + # samplers_for_img2img = [x for x in samplers if x.name != "PLMS"] + samplers_for_img2img = samplers samplers_map.clear() for sampler in all_samplers: samplers_map[sampler.name.lower()] = sampler.name