Extensions/ComfyUI-DAAM
ComfyUI Extension

ComfyUI-DAAM

ComfyUI custom nodes for Diffusion Attentive Attribution Maps (DAAM)

By nisaruj·Created about a year ago·Updated 10 months ago· 51
nisaruj/comfyui-daam
Nodes4
On cloudLocal install
Categorydaam-nodes
Stars51
Updated10 months ago
Readme

ComfyUI DAAM

Download Count Badge

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.

Sample Workflow

✨ Features

  • ✅ Positive / Negative prompt heatmap visualization
  • ✅ Interactive Image Preview with corresponding attention words
  • ✅ SDXL, SD1.5, SD3 support
  • ✅ Flux Dev support (Beta)
<p align="center"> ✨ Featuring an Interactive Preview Node ✨<br/>Discover the top attention words by simply hovering over the image. <br/> <img src="https://github.com/user-attachments/assets/6ce70392-6b04-47bd-a9fb-31b17b66fbd9" width="300" /> </p>

🚀 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
python3 -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.

Node: CLIPTextEncodeWithTokens

KSamplerDAAM

A hooked version of KSampler. During sampling, it records attention maps for later analysis.

Outputs:

  • latent — standard latent output
  • pos_heatmaps — positive prompt's raw heatmaps for input into the analyzer
  • neg_heatmaps — negative prompt's raw heatmaps for input into the analyzer

Node: KSamplerDAAM

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 text
  • tokens — from CLIPTextEncodeWithTokens
  • heatmaps — from KSamplerDAAM
  • 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

Node: DAAMAnalyzer

DAAM Preview (Beta)

Node: DAAM Preview (Beta)

The DAAM Preview node provides an interactive visualization of attention maps.

When the cursor hovers over an image region, the node displays the top attention words associated with that area, ranked by their attention scores. This feature enables clearer interpretation of how specific prompt tokens influence different parts of the generated image.

Inputs:

  • clip — CLIP model used to encode the attention text
  • tokens — from CLIPTextEncodeWithTokens
  • heatmaps — from KSamplerDAAM
  • images — the output images
  • top_tokens — Top k tokens that will be displayed on the tooltip

📷 Example Output

Prompt: A photo of corgi with a cowboy hat riding a skateboard in the park

Attention words: corgi,skateboard,hat,park

DAAM Result

📦 Changelog

  • 0.5.0

    • Added Interactive Preview Node
    • Moved all nodes to daam-nodes category
  • 0.4.0

    • Flux and SD3 initial support
    • Code Refactor and Minor bug fixes
  • 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

This project was adapted from the SD Web UI implementation. Special thanks to @kousw for the original work!