ComfyUI-NAG  by ChenDarYen

Universal negative guidance for diffusion models

Created 4 months ago
275 stars

Top 94.0% on SourcePulse

GitHubView on GitHub
Project Summary

This project provides ComfyUI nodes for Normalized Attention Guidance (NAG), a technique that enhances negative prompting in diffusion models. It aims to improve image and video generation quality and control, particularly for few-step and multi-step sampling processes, benefiting users seeking finer control over generative AI outputs.

How It Works

NAG implements a novel approach to negative guidance by extrapolating attention features. This method restores effective negative prompting in few-step diffusion models and complements Classifier-Free Guidance (CFG) in multi-step sampling. The core advantage lies in its ability to provide stronger, more nuanced control over generated content without the typical artifacts associated with aggressive negative prompting.

Quick Start & Requirements

  • Installation: Replace existing ComfyUI nodes (KSampler, KSampler (Advanced), SamplerCustom, BasicGuider, CFGGuider) with their NAG-equivalent counterparts (KSamplerWithNAG, KSamplerWithNAG (Advanced), SamplerCustomWithNAG, NAGGuider, NAGCFGGuider).
  • Prerequisites: ComfyUI, compatible diffusion models (Flux, Flux Kontext, Wan, Vace Wan, Hunyuan Video, Chroma, SD3.5, SDXL, SD).
  • Key Inputs: nag_scale, nag_tau, nag_alpha, nag_sigma_end. Tuning nag_tau and nag_alpha is recommended for new models, followed by nag_scale for guidance strength. nag_sigma_end can reduce computation.
  • Resources: Supports acceleration via TeaCache, WaveSpeed, and TorchCompileModel.
  • Documentation: Example workflows are available in the ./workflows directory.

Highlighted Details

  • Restores effective negative prompting in few-step diffusion models.
  • Complements CFG in multi-step sampling for improved quality and control.
  • Supports various models including Flux, Wan, Hunyuan Video, Chroma, SD3.5, SDXL, and SD.
  • Offers acceleration options through TeaCache, WaveSpeed, and TorchCompileModel.

Maintenance & Community

  • Actively updated with new node additions and bug fixes (as of July 2025).
  • Supports multiple video generation models.

Licensing & Compatibility

  • The repository is available on GitHub, implying a permissive open-source license, though the specific license is not detailed in the README. Compatibility for commercial use would depend on the underlying ComfyUI license and any specific terms for this extension.

Limitations & Caveats

The README advises users to find optimal nag_tau and nag_alpha values for new models to avoid artifacts, indicating a potential tuning requirement. While it supports many models, specific performance or compatibility nuances may exist for less common configurations.

Health Check
Last Commit

1 day ago

Responsiveness

Inactive

Pull Requests (30d)
4
Issues (30d)
3
Star History
7 stars in the last 30 days

Explore Similar Projects

Starred by Tobi Lutke Tobi Lutke(Cofounder of Shopify), Christian Laforte Christian Laforte(Distinguished Engineer at NVIDIA; Former CTO at Stability AI), and
3 more.

taesd by madebyollin

1.0%
804
Tiny AutoEncoder for Stable Diffusion latents
Created 2 years ago
Updated 6 months ago
Starred by Yineng Zhang Yineng Zhang(Inference Lead at SGLang; Research Scientist at Together AI), Rodrigo Nader Rodrigo Nader(Cofounder of Langflow), and
1 more.

DiffSynth-Studio by modelscope

0.7%
11k
Open-source project for diffusion model exploration
Created 1 year ago
Updated 16 hours ago
Feedback? Help us improve.