ComfyUI-AutomaticCFG
If your image was a pizza and the CFG the temperature of your oven: this is a thermostat that ensures it is always cooked like you want. Also adds a 30% speed increase. For ComfyUI / StableDiffusion
Package profile
- Status
- Verified
- Publisher
- @Extraltodeus
- Source
- GitHub
- Stars
- 432
README
Abandon this boat and jump on this one!
If you liked other functionnalities, I've re-created most in this repository.
In short:
My own version "from scratch" of a self-rescaling CFG / anti-burn. It ain't much but it's honest work.
No more burns and 160% faster gens with the warp drive node.
Now includes custom attention modifiers and interesting presets as well as temperature scaling.
Also just tested and it works with pixart sigma.
Works with SD3 for as long as you don't use any boost feature / cutting the uncond (it's the same thing). 20 steps works nicely.
Note:
The presets are interpreted with eval(). Make sure that you thrust whoever sent a preset to you as it may be used to execute malicious code.
Update:
- Removed and perfected "Uncond Zero" node and moved it to it's own repository
- Removed temperature nodes and set a repository for these
Usage:
77889aa6-a2f6-48bf-8cde-17c9cbfda5fa
That's it!
- The "boost" toggle will turn off the negative guidance when the sigmas are near 1. This doubles the inference speed.
- The negative strength lerp the cond and uncond. Now in normal times the way I do this would burn things to the ground. But since it is initialy an anti-burn it just works. This idea is inspired by the negative prompt weight repository.
- I leave the advanced node for those who are interested. It will not be beneficial to those who do not feel like experimenting.
For 100 steps this is where the sigma are reaching 1:
image
Note: the warp drive node improves the speed a lot more. The average speed is 160% the normal one if used with the AYS scheduler (check the workflow images).
There seem to be a slight improvement in quality when using the boost with my other node CLIP Vector Sculptor text encode using the "mean" normalization option.
Just a note:
Your CFG won't be your CFG anymore. It is turned into a way to guide the CFG/final intensity/brightness/saturation. So don't hesitate to change your habits while trying!
The rest of the explaination:
While this node is connected, this will turn your sampler's CFG scale into something else. This methods works by rescaling the CFG at each step by evaluating the potential average min/max values. Aiming at a desired output intensity (by intensity I mean overall brightness/saturation/sharpness). The base intensity has been arbitrarily chosen by me and your sampler's CFG scale will make this target vary. I have set the "central" CFG at 8. Meaning that at 4 you will aim at half of the desired range while at 16 it will be doubled. This makes it feel slightly like the usual when you're around the normal values.
The CFG behavior during the sampling being automatically set for each channel makes it behave differently and therefores gives different outputs than the usual. From my observations by printing the results while testing, it seems to be going from around 16 at the beginning, to something like 4 near the middle and ends up near ~7. These values might have changed since I've done a thousand tests with different ways but that's to give you an idea, it's just me eyeballing the CLI's output.
I use the upper and lower 25% topk mean value as a reference to have some margin of manoeuver.
It makes the sampling generate overall better quality images. I get much less if not any artifacts anymore and my more creative prompts also tends to give more random, in a g
Nodes in this pack
17 nodes
Nodes in this pack
17 nodes- Automatic CFG
- Automatic CFG - Advanced
- Automatic CFG - Attention modifiers
- Automatic CFG - Attention modifiers tester
- Automatic CFG - Custom attentions
- Automatic CFG - Excellent attention
- Automatic CFG - Negative
- Automatic CFG - Post rescale only
- Automatic CFG - Preset Loader
- Automatic CFG - Unpatch function
- Automatic CFG - Warp Drive
- SAG delayed activation
- Temperature separate settings CLIP SDXL
- Temperature settings CLIP
- Temperature settings SD 1.5
- Temperature settings SDXL
- Zero Uncond CFG - standalone patch (incompatible with the others)
Related resources
5 connections
Related resources
5 connectionsSources
3 sources
Sources
3 sourcesVerified Oct 9
Verified Oct 9
Source excerpts
1 excerpt
Source excerpts
1 excerptSource context: Repo Extraltodeus/ComfyUI-AutomaticCFG
