sd-dynamic-thresholding

1194

Documentation

ComfyUI Custom Nodes: Stable Diffusion Dynamic Thresholding

Overview

This repository provides a set of custom nodes for ComfyUI, an interface for Stable Diffusion, that implements dynamic thresholding for CFG scale management. This capability allows users to manage higher CFG scales without encountering color issues, resulting in improved image outputs during the generation process.

The mechanism works by clamping latents between steps, preventing issues typically caused by elevated CFG scales. This repository can also be used within other UIs like SwarmUI and AUTOMATIC1111 Stable Diffusion WebUI.

Installation

ComfyUI

  1. Ensure you have ComfyUI installed and functioning on your system. Refer to its installation guide if needed.
  2. Make sure you are in the ComfyUI/custom_nodes directory of your ComfyUI installation.
  3. Clone this repository:
    git clone https://github.com/mcmonkeyprojects/sd-dynamic-thresholding
    
  4. Restart ComfyUI to detect and integrate the new nodes.
  5. Add the node by selecting either DynamicThresholdingSimple or DynamicThresholdingFull.
  6. Link your model to the input, and subsequently link the output model to your KSampler's input.

Repository Purpose

This repository is primarily intended to offer an extension capability for efficiently handling high CFG scales without succumbing to color distortions or anomalies. It provides a way to maintain image quality by controlling the latents during intermediate steps in the image generation process.

Node Types

The repository contains two types of nodes, each serving a different level of complexity:

These nodes are implemented in __init__.py as dynthres_comfyui.

Features and Capabilities

  • Dynamic Thresholding: Adjust CFG scales dynamically to prevent color distortion.
  • Ease of Use: Simple integration process, especially for users familiar with ComfyUI.
  • Compatibility: Works with any variant of the KSampler node, including custom implementations, provided they do not overwrite the internal sampling function.

Use Case in ComfyUI Workflows

Implementing dynamic thresholding within ComfyUI workflows enables users to push the boundaries of image generation quality without encountering usual CFG scale limitations. This is particularly beneficial for artists and developers looking to achieve cleaner and more vibrant images by leveraging higher CFG settings.

By adding this mechanism to a workflow, users can expect enhanced control over the visual outcome, maintaining fidelity across different CFG scale configurations.