From 880f6f6c4b37f01772d2537fdb9e7b306d997b43 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Wed, 13 Nov 2024 13:23:24 -0500 Subject: [PATCH] fix denoising strength Signed-off-by: Vladimir Mandic --- TODO.md | 3 +++ modules/control/run.py | 4 ++-- modules/processing_class.py | 4 ++-- modules/processing_diffusers.py | 12 ++++++------ 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/TODO.md b/TODO.md index 2f3f90852..ed3ebfbdb 100644 --- a/TODO.md +++ b/TODO.md @@ -4,6 +4,9 @@ Main ToDo list can be found at [GitHub projects](https://github.com/users/vladma ## Future Candidates +- sd35 ip-adapter +- flux.1 ip-adapter +- flow-match scheudlers: - async lowvram: - fp8: - ipadapter-negative: diff --git a/modules/control/run.py b/modules/control/run.py index d2e1b36ef..c141c8443 100644 --- a/modules/control/run.py +++ b/modules/control/run.py @@ -66,8 +66,8 @@ def control_run(state: str = '', resize_mode_before: int = 0, resize_name_before: str = 'None', resize_context_before: str = 'None', width_before: int = 512, height_before: int = 512, scale_by_before: float = 1.0, selected_scale_tab_before: int = 0, resize_mode_after: int = 0, resize_name_after: str = 'None', resize_context_after: str = 'None', width_after: int = 0, height_after: int = 0, scale_by_after: float = 1.0, selected_scale_tab_after: int = 0, resize_mode_mask: int = 0, resize_name_mask: str = 'None', resize_context_mask: str = 'None', width_mask: int = 0, height_mask: int = 0, scale_by_mask: float = 1.0, selected_scale_tab_mask: int = 0, - denoising_strength: float = 0, batch_count: int = 1, batch_size: int = 1, - enable_hr: bool = False, hr_sampler_index: int = None, hr_denoising_strength: float = 0.3, hr_resize_mode: int = 0, hr_resize_context: str = 'None', hr_upscaler: str = None, hr_force: bool = False, hr_second_pass_steps: int = 20, + denoising_strength: float = 0.0, batch_count: int = 1, batch_size: int = 1, + enable_hr: bool = False, hr_sampler_index: int = None, hr_denoising_strength: float = 0.0, hr_resize_mode: int = 0, hr_resize_context: str = 'None', hr_upscaler: str = None, hr_force: bool = False, hr_second_pass_steps: int = 20, hr_scale: float = 1.0, hr_resize_x: int = 0, hr_resize_y: int = 0, refiner_steps: int = 5, refiner_start: float = 0.0, refiner_prompt: str = '', refiner_negative: str = '', video_skip_frames: int = 0, video_type: str = 'None', video_duration: float = 2.0, video_loop: bool = False, video_pad: int = 0, video_interpolate: int = 0, *input_script_args, diff --git a/modules/processing_class.py b/modules/processing_class.py index 24ec0d8d9..9a5bc088c 100644 --- a/modules/processing_class.py +++ b/modules/processing_class.py @@ -72,7 +72,7 @@ class StableDiffusionProcessing: resize_mode: int = 0, resize_name: str = 'None', resize_context: str = 'None', - denoising_strength: float = 0.3, + denoising_strength: float = 0.0, image_cfg_scale: float = None, initial_noise_multiplier: float = None, # pylint: disable=unused-argument # a1111 compatibility scale_by: float = 1, @@ -100,7 +100,7 @@ class StableDiffusionProcessing: hr_second_pass_steps: int = 0, hr_resize_x: int = 0, hr_resize_y: int = 0, - hr_denoising_strength: float = 0.50, + hr_denoising_strength: float = 0.0, refiner_steps: int = 5, refiner_start: float = 0, refiner_prompt: str = '', diff --git a/modules/processing_diffusers.py b/modules/processing_diffusers.py index 76009d2e1..2164134b1 100644 --- a/modules/processing_diffusers.py +++ b/modules/processing_diffusers.py @@ -177,7 +177,8 @@ def process_hires(p: processing.StableDiffusionProcessing, output): sd_hijack_hypertile.hypertile_set(p, hr=True) latent_upscale = shared.latent_upscale_modes.get(p.hr_upscaler, None) - if (latent_upscale is not None or p.hr_force) and getattr(p, 'hr_denoising_strength', p.denoising_strength) > 0: + strength = p.hr_denoising_strength if p.hr_denoising_strength > 0 else p.denoising_strength + if (latent_upscale is not None or p.hr_force) and strength > 0: p.ops.append('hires') sd_models_compile.openvino_recompile_model(p, hires=True, refiner=False) if shared.sd_model.__class__.__name__ == "OnnxRawPipeline": @@ -185,8 +186,7 @@ def process_hires(p: processing.StableDiffusionProcessing, output): p.hr_force = True # hires - p.denoising_strength = getattr(p, 'hr_denoising_strength', p.denoising_strength) - if p.hr_force and p.denoising_strength == 0: + if p.hr_force and strength == 0: shared.log.warning('HiRes skip: denoising=0') p.hr_force = False if p.hr_force: @@ -204,9 +204,9 @@ def process_hires(p: processing.StableDiffusionProcessing, output): sd_models.move_model(shared.sd_model.unet, devices.device) if hasattr(shared.sd_model, 'transformer'): sd_models.move_model(shared.sd_model.transformer, devices.device) - orig_denoise = p.denoising_strength - p.denoising_strength = getattr(p, 'hr_denoising_strength', p.denoising_strength) update_sampler(p, shared.sd_model, second_pass=True) + orig_denoise = p.denoising_strength + p.denoising_strength = strength hires_args = set_pipeline_args( p=p, model=shared.sd_model, @@ -221,7 +221,7 @@ def process_hires(p: processing.StableDiffusionProcessing, output): output_type='latent', clip_skip=p.clip_skip, image=output.images, - strength=p.denoising_strength, + strength=strength, desc='Hires', ) shared.state.job = 'HiRes'