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 ā good for analyzing and debugging model outputs and LoRA training.
š Example workflows are available in workflows.
This project was adapted from the SD Web UI implementation. Special thanks to @kousw for the original work!
⨠Features
- ā Positive / Negative prompt heatmap visualization
- ā SDXL and SD 1.5 support
- ā Batched input support
š Installation
Now Available on Comfy Registry and Custom Node 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 outputpos_heatmaps
ā positive prompt's raw heatmaps for input into the analyzerneg_heatmaps
ā negative prompt's 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 Output
Prompt: A photo of corgi with a cowboy hat riding a skateboard in the park
Attention words: corgi,skateboard,hat,park
š¦ Changelog
-
0.3.0
- Negative prompt support
- Code Refactor and Minor bug fixes
-
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