Skip to content

valkymaera/sd-channel-offset

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 

Repository files navigation

SD-Channel-Offset

An Automatic1111 WebUI extension allowing an offset to be applied to latent noise per-channel before generation.


About

Latent noise channels in Stable Diffusion don’t directly represent pixel color values, though they may technically relate to RGB or CMYK values. Instead, each channel in the latent space is more conceptually tied to certain features learned in training from such noise or mean values; though they still tend to influence hue. Different models (and different prompts) may respond to offsets on each channel in unique ways, often highlighting or suppressing various conceptual elements, perhaps because they tended to occur in images with higher or lower color means.

Why is this neat?
You can sometimes steer the output toward certain themes or bring out features of your prompt that are hard to directly emphasize. For example Channel 1 often influences how dark, enclosed, or exposed the scene feels, especially if your prompt contains tokens related to those things. This is not guaranteed to be the same for every model or prompt, but there's a lot of overlap to experiment with.


Examples

(The ui in these examples is older but the function is the same. The new UI has a couple check boxes tucked away instead of up front).

Consider the following alien landscape:

landscape

  • Channel 1 Very Low
    The space becomes warmer, shaded, and more enclosed.

    low channel 1

  • Channel 1 Very High
    The scene instead becomes open, exposed, and brighter.

    high channel 1

By tinkering with various channels, you can fine-tune conceptual features, sometimes pushing them beyond what tokens and emphasis alone would accomplish.

sample no offset sample dark offset


Important Notes

  • Channel Range: Channels 5 through 8 are not generally used, though supposedly some models can support up to 8. They’re included here for completeness, but will rarely do anything in my experience.
  • RNG Intercept: This extension works by intercepting rng.py’s ImageRNG.next() method and adding the requested offsets into the generated noise. Other extensions doing similar intercepts may conflict.
  • Model/Prompt Sensitivity: Different models and prompts may respond more or less sensitively to channel offsets.

UI Overview

  1. Drop Mean After Offset

    • Subtracts the final mean value from the noise after all offsets have been applied, effectively “centering” the output.
    • This often brings the composition somewhat closer to the original while maintaining the relative weight of each channel.
    • It can also reduce the intensity of the offsets, since extreme positive/negative values are often pulled back toward zero.
  2. Save Meta

    • If enabled, stores the offset values in the generated image’s metadata (infotext).
    • This is recommended, as it lets you load settings from the image later.

Example: Dropping the Mean

  • Original
    original knight

  • After Offset Tinkering
    offset knight

  • Dropping Mean
    dropped mean knight

These samples use the SDXL model “quadpipe”:
quadpipe on civitai


Experimental / Tinker Options

  1. Drop Mean Before Offset
    • Subtracts the mean of the noise before applying any offsets, centering it early.
  2. Drop Channel Means Before Offset
    • Subtracts the mean of each channel separately before offsets are applied.

These two options can help keep offset changes in a more “healthy” range by reducing extremes in the noise. The overall effect is usually quite subtle, so feel free to ignore them if you don’t want to overcomplicate things.

  1. Apply Only to First Step
    • By default, only the first noise sample has offset applied. Some samplers (e.g. Euler) gather noise every step.
    • If you disable this, offsets will be applied every time noise is injected, making the offsets more pronounced for samplers that apply them more than once.
    • For samplers that only ever gather noise once, this won’t make a difference.

Channel Effects

Below is a grid example from one model/prompt, adjusting each channel in increments of 0.1:

Offset Grid

By mixing and matching these offsets across channels, we can fine-tune lighting and color influences. Here’s a quick demonstration with the same settings as above, but with various channel offsets used like a color filter or stylistic adjustment:

Channel Shifts

About

Automatic1111 extension allowing an offset to be applied to latent noise per-channel before generation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages