diff --git a/CHANGELOG.md b/CHANGELOG.md index 54286e2a9..d4f659b3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,9 +8,7 @@ BLOCKERS: OPTIONAL: - pending `diffusers==0.26.0` - animatediff `enable_free_init` [pr](https://github.com/huggingface/diffusers/pull/6315) -- pipeline `diffusers_sag_scale` [pr](https://github.com/huggingface/diffusers/issues/6443) - wuerstchen v3 [pr](https://github.com/huggingface/diffusers/pull/6487) -- adetailer [fix](https://github.com/Bing-su/adetailer/issues/466) - control api - photomaker api - interrogate api @@ -100,6 +98,10 @@ And it also includes fixes for all reported issues so far - new model from TenencentARC using similar concept as IPAdapter, but with different implementation and allowing full concept swaps between input images and generated images using trigger words - note: trigger word must match exactly one term in prompt for model to work +- [Self-attention guidance](https://github.com/SusungHong/Self-Attention-Guidance) + - simply select scale in advanced menu + - can drastically improve image coherence as well as reduce artifacts + - note: only compatible with some schedulers - **Improvements** - **ui** - check version and **update** SD.Next via UI diff --git a/modules/processing_diffusers.py b/modules/processing_diffusers.py index d92f06f95..1493f68e9 100644 --- a/modules/processing_diffusers.py +++ b/modules/processing_diffusers.py @@ -389,9 +389,14 @@ def process_diffusers(p: StableDiffusionProcessing): def update_pipeline(sd_model, p: StableDiffusionProcessing): if p.sag_scale > 0 and is_txt2img(): - sd_model = sd_models.switch_diffuser_pipe(sd_model, diffusers.StableDiffusionSAGPipeline) - p.extra_generation_params["SAG scale"] = p.sag_scale - p.task_args['sag_scale'] = p.sag_scale + update_sampler(shared.sd_model) + supported = ['DDIMScheduler', 'PNDMScheduler', 'DDPMScheduler', 'DEISMultistepScheduler', 'UniPCMultistepScheduler', 'DPMSolverMultistepScheduler', 'DPMSolverSinlgestepScheduler'] + if sd_model.scheduler.__class__.__name__ in supported: + sd_model = sd_models.switch_diffuser_pipe(sd_model, diffusers.StableDiffusionSAGPipeline) + p.extra_generation_params["SAG scale"] = p.sag_scale + p.task_args['sag_scale'] = p.sag_scale + else: + shared.log.warning(f'SAG incompatible scheduler: current={sd_model.scheduler.__class__.__name__} supported={supported}') return sd_model if len(getattr(p, 'init_images', [])) > 0: diff --git a/modules/ui_sections.py b/modules/ui_sections.py index e037e13c6..d6083686f 100644 --- a/modules/ui_sections.py +++ b/modules/ui_sections.py @@ -108,9 +108,7 @@ def create_advanced_inputs(tab): image_cfg_scale = gr.Slider(minimum=0.0, maximum=30.0, step=0.1, label='Secondary CFG scale', value=6.0, elem_id=f"{tab}_image_cfg_scale") with FormRow(): diffusers_guidance_rescale = gr.Slider(minimum=0.0, maximum=1.0, step=0.05, label='Guidance rescale', value=0.7, elem_id=f"{tab}_image_cfg_rescale", visible=shared.backend == shared.Backend.DIFFUSERS) - # TODO enable SAG once fixed in diffusers - # diffusers_sag_scale = gr.Slider(minimum=0.0, maximum=1.0, step=0.05, label='Self-attention guidance', value=0.0, elem_id=f"{tab}_image_sag_scale", visible=shared.backend == shared.Backend.DIFFUSERS) - diffusers_sag_scale = gr.Slider(minimum=0.0, maximum=1.0, step=0.05, label='Self-attention guidance', value=0.0, elem_id=f"{tab}_image_sag_scale", visible=False) + diffusers_sag_scale = gr.Slider(minimum=0.0, maximum=1.0, step=0.05, label='Self-attention guidance', value=0.0, elem_id=f"{tab}_image_sag_scale", visible=shared.backend == shared.Backend.DIFFUSERS) with FormRow(): clip_skip = gr.Slider(label='CLIP skip', value=1, minimum=1, maximum=14, step=1, elem_id=f"{tab}_clip_skip", interactive=True) with gr.Group():