add self-attention-guidance

This commit is contained in:
Vladimir Mandic
2024-01-19 14:03:51 -05:00
parent 7c8d035edb
commit c4b26c9791
3 changed files with 13 additions and 8 deletions
+4 -2
View File
@@ -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
+8 -3
View File
@@ -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:
+1 -3
View File
@@ -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():