π₯π Apply TKG Noise Advanced
Hand-pick your chroma key color, one latent channel at a time
- model
- MODEL
The manual gearbox version of the TKG trick
The pack's other node, Apply TKG Noise (SD/SDXL), gives you eight preset chroma colors and calls it a day. Apply TKG Noise Advanced hands you the bare recipe: instead of picking "green," you type the per-latent-channel shift yourself, as a comma-separated string. Same TKG-DM mechanism from the same pack - mean-shift the initial noise so the model paints a flat, keyable background, with a gaussian mask protecting the subject in the middle. The difference is you're no longer limited to the eight presets. Off-green, custom brand colors, weird two-tone backdrops you build by chaining nodes - that's what this one exists for.
If you only need a plain green screen, the SDXL node is the one to reach for. Reach for Advanced when the preset list doesn't have your color, or when you want to experiment with what each latent channel actually contributes.
How it works
Like its sibling, this is a model patcher wearing a latent costume. You feed it a MODEL; it returns a cloned model whose sampler wrapper rewrites the first-step noise. Each of the 4 latent channels (SD/SDXL's VAE uses 4; Flux's uses 16, which is why this whole family is SD/SDXL-only) gets its mean shifted by a sign you specify, and a gaussian mask keeps the center of the frame normal so your subject doesn't get recolored. The channels string is the whole twist: one number per channel, where the sign says which direction to push that channel's mean and 0 means "leave it alone." The default, 0, 1, 1, 0, is exactly the green preset under the hood.
The inputs that matter
- channels - comma-separated numbers, one per latent channel. Values are effectively
-1,0, or1;0, 1, 1, 0is green. Want to know what the other presets are? They're all insrc/tkg.pyin the pack'sCOLOR_SETSlist - cyan is0, 1, 0, 0, magenta is0, -1, -1, -1, and so on. Start from a preset and tweak one value to see what it does. - shift (0.11) - how hard the background is pushed toward the color. Higher = flatter, more saturated backdrop; lower = safer for the subject.
- grid_factor (8) - resolution of the protective gaussian mask before upscaling. Default is fine; the author's own comment in the code reads "# idk why."
Output is a single MODEL (the "output latents" tooltip is a lie by omission - it's a patched model). Feed it to the KSampler's model slot, replacing the direct checkpoint connection.
Install
The pack is dependency-free - zero entries in pyproject.toml's dependencies, no model files to download - so install is painless:
- ComfyUI Manager β search "tkg" or "tkg-chroma-key" β install, restart.
- Or:
cd ComfyUI/custom_nodes && git clone https://github.com/p1atdev/comfyui-tkg-chroma-key, restart ComfyUI.
Requires Python β₯ 3.11 and a current-enough ComfyUI to have comfy.patcher_extension (old installs throw on import). The README is thin, but the examples/TKG-Chroma-Key-Advanced.json workflow shows the killer use case: three Advanced nodes chained, each nudging a different set of channels, producing a multi-color background you can key per region. Drag the JSON or its PNG into ComfyUI to load it.
Troubleshooting
- "Channels must be a comma-separated list of four numbers" - you mistyped the string, or used the wrong separator. Commas and spaces are fine (
0, 1, 1, 0); letters are not. It parses eagerly, so this error shows up at queue time, not silently. - Nothing looks different. Check the obvious first: is the output MODEL actually feeding the sampler that's running? Bypass the node and you've just got a normal model. Then confirm you're on SD/SDXL - 4 channels, not Flux's 16; the wrapper asserts the count matches, and Flux trips it.
- Subject has a color cast - your
shiftis too high or a non-zero channel is bleeding through the mask. Lowershift, or zero that channel and re-test. - Background not flat enough - raise
shift, or stack a second Advanced node to reinforce the same channels.
It's a niche, alpha-grade academic port with almost no community footprint, and the channel-strings UI is unfriendly until you've seen a preset's numbers. But once you decode the recipes, it's the most direct way to get a specific keyable color out of an SD/SDXL model without training.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | β | |
| channels | STRING | 0, 1, 1, 0 | β |
| shift | FLOAT | 0.110β1 | β |
| grid_factor | INT | 81β16 | β |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MODEL | MODEL | Output latents with TKG noise applied |