ComfyUI Extension: ComfyUI-DAAM
ComfyUI custom nodes for Diffusion Attentive Attribution Maps (DAAM)
Custom Nodes (0)
README
ComfyUI DAAM
ComfyUI custom nodes for Diffusion Attentive Attribution Maps (DAAM)
This extension enables visualization of cross-attention heatmaps within Stable Diffusion models, showing exactly which parts of the image correspond to specific words in the prompt.
Tested with SDXL and SD 1.5 models.
Example workflows are available in workflows.
This project was adapted from the SD Web UI implementation. Special thanks to @kousw for the original work!
Installation
Now Available on Comfy Registry and ComfyUI Manager!
Manual Install
Clone this repo into your ComfyUI custom_nodes
directory:
git clone https://github.com/nisaruj/comfyui-daam.git
Then install the required packages
cd comfyui-daam
python -s -m pip install -r requirements.txt
Restart ComfyUI.
DAAM Nodes
CLIPTextEncodeWithTokens
Identical to CLIPTextEncode
but also outputs the tokenized prompt required for the analysis.
KSamplerDAAM
A hooked version of KSampler
. During sampling, it records attention maps for later analysis.
Outputs:
latent
— standard latent outputheatmaps
— raw heatmaps for input into the analyzer
DAAMAnalyzer
This node generates overlay heatmaps that show which parts of the image correspond to selected words in the prompt.
Inputs:
clip
— CLIP model used to encode the attention texttokens
— fromCLIPTextEncodeWithTokens
heatmaps
— fromKSamplerDAAM
images
— the output images to overlay the heatmaps- A text box for comma-separated words to generate heatmaps
Output:
- A batch of images with word-level heatmaps overlaid
Example Result
Prompt: A photo of corgi with a cowboy hat riding a skateboard in the park
Attention Words: corgi,skateboard,hat,park
Changelog
- 0.2.0
- Added support for batched inputs
- SD 1.5 models compatibility
- Bug fixes and stability improvements
- 0.1.1
- Initial Version with SDXL support