Kosinkadink / ComfyUI-Advanced-ControlNet

ControlNet scheduling and masking nodes with sliding context support
GNU General Public License v3.0
435 stars 43 forks source link

ComfyUI-Advanced-ControlNet

Nodes for scheduling ControlNet strength across timesteps and batched latents, as well as applying custom weights and attention masks. The ControlNet nodes here fully support sliding context sampling, like the one used in the ComfyUI-AnimateDiff-Evolved nodes. Currently supports ControlNets, T2IAdapters, ControlLoRAs, ControlLLLite, SparseCtrls, SVD-ControlNets, and Reference.

Custom weights allow replication of the "My prompt is more important" feature of Auto1111's sd-webui ControlNet extension via Soft Weights, and the "ControlNet is more important" feature can be granularly controlled by changing the uncond_multiplier on the same Soft Weights.

ControlNet preprocessors are available through comfyui_controlnet_aux nodes.

Features

Table of Contents:

Scheduling Explanation

The two core concepts for scheduling are Timestep Keyframes and Latent Keyframes.

Timestep Keyframes hold the values that guide the settings for a controlnet, and begin to take effect based on their start_percent, which corresponds to the percentage of the sampling process. They can contain masks for the strengths of each latent, control_net_weights, and latent_keyframes (specific strengths for each latent), all optional.

Latent Keyframes determine the strength of the controlnet for specific latents - all they contain is the batch_index of the latent, and the strength the controlnet should apply for that latent. As a concept, latent keyframes achieve the same affect as a uniform mask with the chosen strength value.

advcn_image

Nodes

The ControlNet nodes provided here are the Apply Advanced ControlNet and Load Advanced ControlNet Model (or diff) nodes. The vanilla ControlNet nodes are also compatible, and can be used almost interchangeably - the only difference is that at least one of these nodes must be used for Advanced versions of ControlNets to be used (important for sliding context sampling, like with AnimateDiff-Evolved).

Key:

Apply Advanced ControlNet

image

Same functionality as the vanilla Apply Advanced ControlNet (Advanced) node, except with Advanced ControlNet features added to it. Automatically converts any ControlNet from ControlNet loaders into Advanced versions.

Inputs

Outputs

Load Advanced ControlNet Model

image

Loads a ControlNet model and converts it into an Advanced version that supports all the features in this repo. When used with Apply Advanced ControlNet node, there is no reason to use the timestep_keyframe input on this node - use timestep_kf on the Apply node instead.

Inputs

Outputs

Timestep Keyframe

image

Scheduling node across timesteps (sampling steps) based on the set start_percent. Chaining Timestep Keyframes allows ControlNet scheduling across sampling steps (percentage-wise), through a timestep keyframe schedule.

Inputs

Outputs

Timestep Keyframe Interpolation

image

Allows to create Timestep Keyframe with interpolated strength values in a given percent range. (The first generated keyframe will have guarantee_steps=1, rest that follow will have guarantee_steps=0).

Inputs

Outputs

Timestep Keyframe From List

image

Allows to create Timestep Keyframe via a list of floats, such as with Batch Value Schedule from ComfyUI_FizzNodes nodes. (The first generated keyframe will have guarantee_steps=1, rest that follow will have guarantee_steps=0).

Inputs

Outputs

Latent Keyframe

image

A singular Latent Keyframe, selects the strength for a specific batch_index. If batch_index is not present during sampling, will simply have no effect. Can be chained with any other Latent Keyframe-type node to create a latent keyframe schedule.

Inputs

Outputs

Latent Keyframe Group

image

Allows to create Latent Keyframes via individual indeces or python-style ranges.

Inputs

Outputs

Latent Keyframe Interpolation

image

Allows to create Latent Keyframes with interpolated values in a range.

Inputs

Outputs

Latent Keyframe From List

image

Allows to create Latent Keyframes via a list of floats, such as with Batch Value Schedule from ComfyUI_FizzNodes nodes.

Inputs

Outputs

There are more nodes to document and show usage - will add this soon! TODO