Nodes Browser

ComfyDeploy: How Adaptive Guidance for ComfyUI works in ComfyUI?

What is Adaptive Guidance for ComfyUI?

An implementation of adaptive guidance for ComfyUI See [a/https://bcv-uniandes.github.io/adaptiveguidance-wp](https://bcv-uniandes.github.io/adaptiveguidance-wp)

How to install it in ComfyDeploy?

Head over to the machine page

  1. Click on the "Create a new machine" button
  2. Select the Edit build steps
  3. Add a new step -> Custom Node
  4. Search for Adaptive Guidance for ComfyUI and select it
  5. Close the build step dialig and then click on the "Save" button to rebuild the machine

Adaptive Guidance for ComfyUI

An implementation of adaptive guidance for ComfyUI

See https://bcv-uniandes.github.io/adaptiveguidance-wp/

Import this workflow into ComfyUI to compare Adaptive Guidance vs. normal CFG.

What

There's an AdaptiveGuidance node (under sampling/custom_sampling/guiders) that can be used with SamplerCustomAdvanced. Normally, you should keep the threshold quite high, between 0.99 and 1.0

The node calculates the cosine similarity between the u-net's conditional and unconditional output ("positive" and "negative" prompts) and once the similarity crosses the specified threshold, it sets CFG to 1.0, effectively skipping negative prompt calculations and speeding up inference.

I'm not sure if the cosine similarity calculation matches the original paper since I had to translate from maths to Python, but it appears to work.

Uncond zero

Set uncond_zero_scale to > 0 to enable "uncond zero" CFG after the normal CFG gets disabled. Stolen from https://github.com/Extraltodeus/Uncond-Zero-for-ComfyUI

It seems to work slightly better than just running without CFG, but YMMV

Note: this functionality is unstable and will probably change, so using it means your workflows likely won't be perfectly reproducible.