Skip to content

Perturbed-Attention Guidance for ComfyUI and SD Forge

License

Notifications You must be signed in to change notification settings

Polyphron/sd-perturbed-attention

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Perturbed-Attention Guidance for ComfyUI/Forge

Implementation of Self-Rectifying Diffusion Sampling with Perturbed-Attention Guidance (D. Ahn et al.) as an extension for ComfyUI and SD WebUI Forge.

Works with SD1.5, SDXL and Stable Cascade.

Note

Paper and demo suggest using CFG scale 4.0 with PAG scale 3.0 applied to U-Net's middle layer 0, but feel free to experiment.

Sampling speed without adaptive_scale is similar to Self-Attention Guidance (x0.6 of usual it/s).

Installation

ComfyUI

git clone https://github.com/pamparamm/sd-perturbed-attention.git into ComfyUI/custom-nodes/ folder.

comfyui-node

SD WebUI (Forge)

git clone https://github.com/pamparamm/sd-perturbed-attention.git into stable-diffusion-webui-forge/extensions/ folder.

forge-script

SD WebUI (Auto1111)

Use PAG implementation from sd-webui-incantations extension.

Parameters

  • scale: PAG scale, has some resemblance to CFG scale - higher values can both increase structural coherence of the image and oversaturate/fry it entirely.
  • adaptive_scale: PAG dampening factor, it penalizes PAG during late denoising stages, resulting in overall speedup: 0.0 means no penalty and 1.0 completely removes PAG.
  • unet_block: Part of U-Net to which PAG is applied, original paper suggests to use middle.
  • unet_block_id: Id of U-Net layer in a selected block to which PAG is applied. PAG can be applied only to layers containing Self-attention blocks.

About

Perturbed-Attention Guidance for ComfyUI and SD Forge

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%