ComfyUI Extension: Dynamic Thresholding
Adds nodes for Dynamic Thresholding, CFG scheduling, and related techniques.
Custom Nodes (420)
- ACEPlusFFTConditioning~
- ACEPlusFFTProcessor~
- ACEPlusFFTLoader~
- ACEPlusLoraConditioning~
- ACEPlusLoraProcessor~
- AddNoise
- Adaptive Projected Guidance
- Audio Adjust Volume
- Audio Concat
- Audio Merge
- BasicGuider
- BasicScheduler
- BetaSamplingScheduler
- ByteDance First-Last-Frame to Video
- ByteDance Image Edit
- ByteDance Image
- ByteDance Reference Images to Video
- ByteDance Image to Video
- ByteDance Seedream 4
- ByteDance Text to Video
- Case Converter
- CFGGuider
- Load Checkpoint With Config (DEPRECATED)
- Load Checkpoint
- Save Checkpoint
- Load CLIP
- CLIPMergeAdd
- CLIPMergeSimple
- CLIPMergeSubtract
- CLIPSave
- CLIP Set Last Layer
- CLIP Text Encode (Prompt)
- CLIPTextEncodeFlux
- CLIPTextEncodeHunyuanDiT
- CLIP Text Encode for Lumina2
- CLIPTextEncodeSD3
- CLIP Vision Encode
- Load CLIP Vision
- Combine Hooks [2]
- Combine Hooks [4]
- Combine Hooks [8]
- ConditioningAverage
- Conditioning (Combine)
- Conditioning (Concat)
- Conditioning (Set Area)
- Conditioning (Set Area with Percentage)
- ConditioningSetAreaPercentageVideo
- ConditioningSetAreaStrength
- Cond Set Default Combine
- Conditioning (Set Mask)
- Cond Set Props
- Cond Set Props Combine
- ConditioningSetTimestepRange
- ConditioningStableAudio
- Timesteps Range
- ConditioningZeroOut
- Context Windows (Manual)
- Apply ControlNet (OLD)
- Apply ControlNet
- Apply Controlnet with VAE
- ControlNetInpaintingAliMamaApply
- Load ControlNet Model
- Create Hook Keyframe
- Create Hook Keyframes From Floats
- Create Hook Keyframes Interp.
- Create Hook LoRA
- Create Hook LoRA (MO)
- Create Hook Model as LoRA
- Create Hook Model as LoRA (MO)
- Create Video
- CropMask
- Load ControlNet Model (diff)
- Differential Diffusion
- DiffusersLoader
- DisableNoise
- DualCFGGuider
- DualCLIPLoader
- DynamicThresholdingFull
- DynamicThresholdingSimple
- EasyCache
- Empty Audio
- EmptyHunyuanImageLatent
- EmptyHunyuanLatentVideo
- EmptyImage
- Empty Latent Audio
- EmptyLatentHunyuan3Dv2
- Empty Latent Image
- EmptySD3LatentImage
- ExponentialScheduler
- ExtendIntermediateSigmas
- FeatherMask
- FlipSigmas
- FluxDisableGuidance
- FluxGuidance
- FluxKontextImageScale
- Flux.1 Kontext [max] Image
- FluxKontextMultiReferenceLatentMethod
- Flux.1 Kontext [pro] Image
- Flux.1 Canny Control Image
- Flux.1 Depth Control Image
- Flux.1 Expand Image
- Flux.1 Fill Image
- Flux 1.1 [pro] Ultra Image
- FreeU
- FreeU_V2
- FreSca
- Google Gemini Image
- Gemini Input Files
- Google Gemini
- Get Image Size
- Get Video Components
- GLIGENLoader
- GLIGENTextBoxApply
- GrowMask
- Hunyuan3Dv2Conditioning
- Hunyuan3Dv2ConditioningMultiView
- HunyuanImageToVideo
- HunyuanRefinerLatent
- HypernetworkLoader
- Ideogram V1
- Ideogram V2
- Ideogram V3
- ImageAddNoise
- Batch Images
- ImageColorToMask
- ImageCompositeMasked
- Image Crop
- ImageFlip
- ImageFromBatch
- Invert Image
- Image Only Checkpoint Loader (img2vid model)
- ImageOnlyCheckpointSave
- Pad Image for Outpainting
- ImageRotate
- Upscale Image
- Upscale Image By
- ImageScaleToMaxDimension
- Image Stitch
- Convert Image to Mask
- Upscale Image (using Model)
- InpaintModelConditioning
- InvertMask
- Join Image with Alpha
- KarrasScheduler
- Kling Image to Video (Camera Control)
- Kling Camera Controls
- Kling Text to Video (Camera Control)
- Kling Dual Character Video Effects
- Kling Image to Video
- Kling Image Generation
- Kling Lip Sync Video with Audio
- Kling Lip Sync Video with Text
- Kling Video Effects
- Kling Start-End Frame to Video
- Kling Text to Video
- Kling Video Extend
- Kling Virtual Try On
- KSampler
- KSampler (Advanced)
- KSamplerSelect
- LaplaceScheduler
- LatentAdd
- LatentApplyOperation
- LatentApplyOperationCFG
- LatentBatch
- LatentBatchSeedBehavior
- Latent Blend
- Latent Composite
- LatentCompositeMasked
- LatentConcat
- Crop Latent
- LatentCut
- Flip Latent
- Latent From Batch
- LatentInterpolate
- LatentMultiply
- LatentOperationSharpen
- LatentOperationTonemapReinhard
- Rotate Latent
- LatentSubtract
- Upscale Latent
- Upscale Latent By
- LazyCache
- Load 3D
- Load 3D - Animation
- Load Audio
- Load Image
- Load Image (as Mask)
- Load Image (from Outputs)
- Load Image Dataset from Folder
- Load Image and Text Dataset from Folder
- LoadLatent
- Load Video
- Load LoRA
- LoraLoaderModelOnly
- Load LoRA Model
- Extract and Save Lora
- Plot Loss Graph
- Luma Concepts
- Luma Image to Image
- Luma Text to Image
- Luma Image to Video
- Luma Reference
- Luma Text to Video
- Mahiro is so cute that she deserves a better guidance function!! (。・ω・。)
- MaskComposite
- MaskPreview
- Convert Mask to Image
- MiniMax Hailuo Video
- MiniMax Image to Video
- MiniMax Text to Video
- ModelComputeDtype
- ModelMergeAdd
- ModelMergeAuraflow
- ModelMergeBlocks
- ModelMergeCosmos14B
- ModelMergeCosmos7B
- ModelMergeCosmosPredict2_14B
- ModelMergeCosmosPredict2_2B
- ModelMergeFlux1
- ModelMergeLTXV
- ModelMergeMochiPreview
- ModelMergeQwenImage
- ModelMergeSD1
- ModelMergeSD2
- ModelMergeSD3_2B
- ModelMergeSD35_Large
- ModelMergeSDXL
- ModelMergeSimple
- ModelMergeSubtract
- ModelMergeWAN2_1
- ModelPatchLoader
- ModelSamplingAuraFlow
- ModelSamplingContinuousEDM
- ModelSamplingContinuousV
- ModelSamplingDiscrete
- ModelSamplingFlux
- ModelSamplingSD3
- ModelSamplingStableCascade
- ModelSave
- Moonvalley Marey Image to Video
- Moonvalley Marey Text to Video
- Moonvalley Marey Video to Video
- ImageMorphology
- OpenAI ChatGPT Advanced Options
- OpenAI ChatGPT
- OpenAI DALL·E 2
- OpenAI DALL·E 3
- OpenAI GPT Image 1
- OpenAI ChatGPT Input Files
- OpenAI Sora - Video
- Cond Pair Combine
- Cond Pair Set Default Combine
- Cond Pair Set Props
- Cond Pair Set Props Combine
- PatchModelAddDownscale (Kohya Deep Shrink)
- Perp-Neg (DEPRECATED by PerpNegGuider)
- Pikadditions (Video Object Insertion)
- Pikaffects (Video Effects)
- Pika Image to Video
- Pika Scenes (Video Image Composition)
- Pika Start and End Frame to Video
- Pika Swaps (Video Object Replacement)
- Pika Text to Video
- PixVerse Image to Video
- PixVerse Template
- PixVerse Text to Video
- PixVerse Transition Video
- PolyexponentialScheduler
- Porter-Duff Image Composite
- Preview 3D
- Preview 3D - Animation
- Preview Any
- Preview Audio
- Preview Image
- Boolean
- Float
- Int
- String
- String (Multiline)
- QwenImageDiffsynthControlnet
- RandomNoise
- Rebatch Images
- Rebatch Latents
- Record Audio
- Recraft Color RGB
- Recraft Controls
- Recraft Creative Upscale Image
- Recraft Crisp Upscale Image
- Recraft Image Inpainting
- Recraft Image to Image
- Recraft Remove Background
- Recraft Replace Background
- Recraft Style - Digital Illustration
- Recraft Style - Infinite Style Library
- Recraft Style - Logo Raster
- Recraft Style - Realistic Image
- Recraft Text to Image
- Recraft Text to Vector
- Recraft Vectorize Image
- Regex Extract
- Regex Match
- Regex Replace
- RepeatImageBatch
- Repeat Latent Batch
- RescaleCFG
- ResizeAndPadImage
- Rodin 3D Generate - Detail Generate
- Rodin 3D Generate - Gen-2 Generate
- Rodin 3D Generate - Regular Generate
- Rodin 3D Generate - Sketch Generate
- Rodin 3D Generate - Smooth Generate
- Runway First-Last-Frame to Video
- Runway Image to Video (Gen3a Turbo)
- Runway Image to Video (Gen4 Turbo)
- Runway Text to Image
- SamplerCustom
- SamplerCustomAdvanced
- SamplerDPMAdaptative
- SamplerDPMPP_2M_SDE
- SamplerDPMPP_2S_Ancestral
- SamplerDPMPP_3M_SDE
- SamplerDPMPP_SDE
- SamplerER_SDE
- SamplerEulerAncestral
- SamplerEulerAncestralCFG++
- SamplerEulerCFG++
- SamplerLMS
- SamplerSASolver
- SamplingPercentToSigma
- SaveAnimatedPNG
- SaveAnimatedWEBP
- Save Audio (FLAC)
- Save Audio (MP3)
- Save Audio (Opus)
- SaveGLB
- Save Image
- SaveLatent
- Save LoRA Weights
- SaveSVGNode
- Save Video
- SDTurboScheduler
- Self-Attention Guidance
- Set CLIP Hooks
- SetFirstSigma
- Set Hook Keyframes
- Set Latent Noise Mask
- SetUnionControlNetType
- SkipLayerGuidanceDiT
- SkipLayerGuidanceDiTSimple
- SkipLayerGuidanceSD3
- SolidMask
- Split Audio Channels
- Split Image with Alpha
- SplitSigmas
- SplitSigmasDenoise
- Stability AI Audio Inpaint
- Stability AI Audio To Audio
- Stability AI Stable Diffusion 3.5 Image
- Stability AI Stable Image Ultra
- Stability AI Text To Audio
- Stability AI Upscale Conservative
- Stability AI Upscale Creative
- Stability AI Upscale Fast
- Compare
- Concatenate
- Contains
- Length
- Replace
- Substring
- Trim
- Apply Style Model
- Load Style Model
- SVD_img2vid_Conditioning
- Tangential Damping CFG
- TextEncodeHunyuanVideo_ImageToVideo
- ThresholdMask
- Train LoRA
- Trim Audio Duration
- TripleCLIPLoader
- Tripo: Convert model
- Tripo: Image to Model
- Tripo: Multiview to Model
- Tripo: Refine Draft model
- Tripo: Retarget rigged model
- Tripo: Rig model
- Tripo: Text to Model
- Tripo: Texture model
- unCLIPCheckpointLoader
- unCLIPConditioning
- Load Diffusion Model
- Load Upscale Model
- USOStyleReference
- VAE Decode
- VAE Decode Audio
- VAEDecodeHunyuan3D
- VAE Decode (Tiled)
- VAE Encode
- VAE Encode Audio
- VAE Encode (for Inpainting)
- VAE Encode (Tiled)
- Load VAE
- VAESave
- Google Veo 3 Video Generation
- Google Veo 2 Video Generation
- VideoLinearCFGGuidance
- VideoTriangleCFGGuidance
- Vidu Image To Video Generation
- Vidu Reference To Video Generation
- Vidu Start End To Video Generation
- Vidu Text To Video Generation
- VoxelToMesh
- VoxelToMeshBasic
- VPScheduler
- WAN Context Windows (Manual)
- Wan Image to Image
- Wan Image to Video
- Wan Text to Image
- Wan Text to Video
- Webcam Capture
README
Stable Diffusion Dynamic Thresholding (CFG Scale Fix)
Concept
Extension for SwarmUI, ComfyUI, and AUTOMATIC1111 Stable Diffusion WebUI that enables a way to use higher CFG Scales without color issues.
This works by clamping latents between steps. You can read more here or here or this tweet.
Credit
The core functionality of this PR was originally developed by Birch-san and ported to the WebUI by dtan3847, then converted to an Auto WebUI extension and given a UI by mcmonkey4eva, further development and research done by mcmonkey4eva and JDMLeverton. Ported by ComfyUI by TwoDukes and mcmonkey4eva. Ported to SwarmUI by mcmonkey4eva.
Examples


Demo Grid
View at https://sd.mcmonkey.org/dynthresh/.

(Was generated via this YAML config for the Infinite Grid Generator)
Installation and Usage
SwarmUI
- Supported out-of-the-box on default installations.
- If using a custom installation, just make sure the backend you use has this repo installed per the instructions specific to the backend as written below.
- It's under the "Display Advanced Options" parameter checkbox.
Auto WebUI
- You must have the AUTOMATIC1111 Stable Diffusion WebUI already installed and working. Refer to that project's readme for help with that.
- Open the WebUI, go to the
Extensionstab - -EITHER- Option A:
- go to the
Availabletab with - click
Load from(with the default list) - Scroll down to find
Dynamic Thresholding (CFG Scale Fix), or useCTRL+Fto find it
- go to the
- -OR- Option B:
- Click on
Install from URL - Copy/paste this project's URL into the
URL for extension's git repositorytextbox:https://github.com/mcmonkeyprojects/sd-dynamic-thresholding
- Click on
- Click
Install - Restart or reload the WebUI
- Go to txt2img or img2img
- Check the
Enable Dynamic Thresholding (CFG Scale Fix)box - Read the info on-page and set the sliders where you want em.
- Click generate.
ComfyUI
- Must have ComfyUI already installed and working. Refer to that project's readme for help with that.
- -EITHER- Option A: (TODO: Manager install)
- -OR- Option B:
cd ComfyUI/custom_nodesgit clone https://github.com/mcmonkeyprojects/sd-dynamic-thresholding- restart ComfyUI
- Add node
advanced/mcmonkey/DynamicThresholdingSimple(orFull) - Link your model to the input, and then link the output model to your KSampler's input

Supported Auto WebUI Extensions
- This can be configured within the Infinity Grid Generator extension, see the readme of that project for details.
ComfyUI Compatibility
- This would work with any variant of the
KSamplernode, including custom ones, so long as they do not totally override the internal sampling function (most don't).
Licensing pre-note:
This is an open source project, provided entirely freely, for everyone to use and contribute to.
If you make any changes that could benefit the community as a whole, please contribute upstream.
The short of the license is:
You can do basically whatever you want, except you may not hold any developer liable for what you do with the software.
The long version of the license follows:
The MIT License (MIT)
Copyright (c) 2023 Alex "mcmonkey" Goodwin
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.