From 9b38a5dc58298cb401d64ce718a74006a1cc57b6 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Wed, 2 Jul 2025 08:14:45 -0400 Subject: [PATCH] add kontext inpainting Signed-off-by: Vladimir Mandic --- CHANGELOG.md | 5 ++++- installer.py | 2 +- modules/model_flux.py | 2 +- modules/processing_helpers.py | 24 ++++++++++++------------ modules/sd_vae_taesd.py | 1 + 5 files changed, 19 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 695ea79ce..fb7ea4f5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,9 @@ # Change Log for SD.Next -## Update for 2025-07-01 +## Update for 2025-07-02 +- **Models** + - Add **FLUX.1-Kontext-Dev** inpaint workflow - **UI** - major update to modernui layout - **Core** @@ -13,6 +15,7 @@ - **Fixes** - allow theme type `None` to be set in config - installer dont cache installed state + - fix Cosmos-Predict2 retrying TAESD download ## Update for 2025-06-30 diff --git a/installer.py b/installer.py index e2ef83392..2d6f7c727 100644 --- a/installer.py +++ b/installer.py @@ -554,7 +554,7 @@ def check_diffusers(): t_start = time.time() if args.skip_all or args.skip_git or args.experimental: return - sha = '00f95b9755718aabb65456e791b8408526ae6e76' # diffusers commit hash + sha = 'd6fa3298fa14db874b71b3fc5ebcefae99e15f45' # diffusers commit hash pkg = pkg_resources.working_set.by_key.get('diffusers', None) minor = int(pkg.version.split('.')[1] if pkg is not None else 0) cur = opts.get('diffusers_version', '') if minor > 0 else '' diff --git a/modules/model_flux.py b/modules/model_flux.py index 518e396d7..6194cfbd1 100644 --- a/modules/model_flux.py +++ b/modules/model_flux.py @@ -323,7 +323,7 @@ def load_flux(checkpoint_info, diffusers_load_config): # triggered by opts.sd_ch from diffusers import pipelines pipelines.auto_pipeline.AUTO_TEXT2IMAGE_PIPELINES_MAPPING["flux1kontext"] = diffusers.FluxKontextPipeline pipelines.auto_pipeline.AUTO_IMAGE2IMAGE_PIPELINES_MAPPING["flux1kontext"] = diffusers.FluxKontextPipeline - pipelines.auto_pipeline.AUTO_INPAINT_PIPELINES_MAPPING["flux1kontext"] = diffusers.FluxKontextPipeline + pipelines.auto_pipeline.AUTO_INPAINT_PIPELINES_MAPPING["flux1kontext"] = diffusers.FluxKontextInpaintPipeline else: cls = diffusers.FluxPipeline diff --git a/modules/processing_helpers.py b/modules/processing_helpers.py index 5d1647f8f..cdfe774bc 100644 --- a/modules/processing_helpers.py +++ b/modules/processing_helpers.py @@ -462,12 +462,12 @@ def fix_prompts(p, prompts, negative_prompts, prompts_2, negative_prompts_2): def calculate_base_steps(p, use_denoise_start, use_refiner_start): if len(getattr(p, 'timesteps', [])) > 0: return None - if not is_txt2img(): - cls = shared.sd_model.__class__.__name__ + cls = shared.sd_model.__class__.__name__ + if 'Flex' in cls or 'HiDreamImageEditingPipeline' in cls or 'Kontext' in cls: + steps = p.steps + elif not is_txt2img(): if cls in sd_models.i2i_pipes: steps = p.steps - elif 'Flex' in cls or 'HiDreamImageEditingPipeline' in cls or 'Kontext' in cls: - steps = p.steps elif use_denoise_start and (shared.sd_model_type == 'sdxl'): steps = p.steps // (1 - p.refiner_start) elif p.denoising_strength > 0: @@ -483,9 +483,10 @@ def calculate_base_steps(p, use_denoise_start, use_refiner_start): def calculate_hires_steps(p): - # if len(getattr(p, 'timesteps', [])) > 0: - # return None - if p.hr_second_pass_steps > 0: + cls = shared.sd_model.__class__.__name__ + if 'Flex' in cls or 'HiDreamImageEditingPipeline' in cls or 'Kontext' in cls: + steps = p.steps + elif p.hr_second_pass_steps > 0: steps = (p.hr_second_pass_steps // p.denoising_strength) + 1 elif p.denoising_strength > 0: steps = (p.steps // p.denoising_strength) + 1 @@ -496,18 +497,17 @@ def calculate_hires_steps(p): def calculate_refiner_steps(p): - # if len(getattr(p, 'timesteps', [])) > 0: - # return None - if "StableDiffusionXL" in shared.sd_refiner.__class__.__name__: + cls = shared.sd_model.__class__.__name__ + if 'Flex' in cls or 'HiDreamImageEditingPipeline' in cls or 'Kontext' in cls: + steps = p.steps + elif "StableDiffusionXL" in shared.sd_refiner.__class__.__name__: if p.refiner_start > 0 and p.refiner_start < 1: - #steps = p.refiner_steps // (1 - p.refiner_start) # SDXL with denoise strenght steps = (p.refiner_steps // (1 - p.refiner_start) // 2) + 1 elif p.denoising_strength > 0: steps = (p.refiner_steps // p.denoising_strength) + 1 else: steps = 0 else: - #steps = p.refiner_steps # SD 1.5 with denoise strenght steps = (p.refiner_steps * 1.25) + 1 debug_steps(f'Steps: type=refiner input={p.refiner_steps} output={steps} start={p.refiner_start} denoise={p.denoising_strength}') return max(1, int(steps)) diff --git a/modules/sd_vae_taesd.py b/modules/sd_vae_taesd.py index 3ef7e123d..079e8a40b 100644 --- a/modules/sd_vae_taesd.py +++ b/modules/sd_vae_taesd.py @@ -63,6 +63,7 @@ def get_model(model_type = 'decoder', variant = None): model_cls = 'sdxl' elif model_cls not in supported: warn_once(f'cls={shared.sd_model.__class__.__name__} type={model_cls} unsuppported', variant=variant) + return None variant = variant or shared.opts.taesd_variant folder = os.path.join(paths.models_path, "TAESD") os.makedirs(folder, exist_ok=True)