ColorGradeSampler
The sampler that drags color toward a reference while it denoises
- reference
- SAMPLER
The difference between a good color match and a pasted-on one is when you apply it. Recolor a finished image and the model has already committed to its own palette - you're fighting the result. Do it mid-denoise, while the image is still being painted, and the sampler can keep building detail around the palette you imposed. That's the whole idea behind ColorGradeSampler: it's a real sampler object that forces the latent toward a reference's color statistics on a window of sampling steps.
It's the fancy sibling of the ColorGrading node from the same pack (yasser-baalla/comfyUI-SemanticImageFetch). Where ColorGrading is a one-shot latent transform, this one bakes the same mean/std color matching into the sampling loop itself. More moving parts, more knobs, more to get wrong - but the results can look noticeably more integrated.
How it works
Under the hood it wraps the classic Karras et al. (2022) Algorithm 2 Euler sampler - the same math ComfyUI ships for its plain "euler" - and injects one extra step. On each denoising step i where start <= i <= end, it takes the model's denoised prediction and runs adjust_latent on it: normalize that predicted clean image's per-channel mean/std, then shift and rescale it to the reference latent's mean and std. The Euler step then continues from the adjusted version.
That's why the window exists. Early and middle sampling steps are where composition and broad color get decided; late steps refine detail. Grade the whole run and you force the palette so hard the model fights you at the end - flat, muddy results. Grade just the first chunk and the sampler is free to settle natural detail in the final steps. start and end are your control over that tradeoff.
The inputs that matter
- reference - a LATENT whose color you want to inherit. Same trap as ColorGrading: it's a latent, not an image. VAE Encode your reference picture first.
- start (default 0) and end (default 15) - sampling step indices, not percentages and not CFG values. Beginners read "15" and think it's a dial out of 100; it's a step index out of however many steps your sampler runs. With a 20-step run, the default grades steps 0–15 and leaves 4 free. At 10 steps, everything gets graded.
The output is a SAMPLER object, and here's the gotcha that trips everyone: it does not plug into the sampler dropdown on a plain KSampler. That's a string selector. A SAMPLER-type output like this wires into a SamplerCustom node's sampler input - the same slot the custom sampler packs use. Put SamplerCustom in your graph, connect this node's output there, and it just works.
Install
Included in the pack, installed once. ComfyUI Manager → search "SemanticImageFetch", or:
cd ComfyUI/custom_nodes
git clone https://github.com/yasser-baalla/comfyUI-SemanticImageFetch
Restart, done. No requirements.txt, no model downloads - the code leans on ComfyUI's own KSAMPLER and to_d utilities, so the only real dependency is the ComfyUI you already run.
The fiddly bits
Two things bite people, both visible in the source. First, end must be strictly greater than start - the node raises ValueError("End must be greater than start.") and there's no auto-correction. Second, the window is compared against the actual number of sigma steps your run uses, so values past your step count don't error - they just silently grade the entire run (or, if start is beyond the step count, silently do nothing). If the effect looks too strong or too weak, that's your cue to shrink or widen the window, not to reach for a CFG knob.
One more honest note: it's an Euler-family sampler, so it trades the fancy convergence of DPM++ 2M or the modern res-sampler packs for this one color trick. If you need both modern sampling quality and color matching, a post-hoc ColorGrading on the finished latent is the safer bet - this node is the more integrated but more opinionated option.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| reference | LATENT | The reference image | |
| start | INT | 00–10000 | The starting point of the color grading |
| end | INT | 150–10000 | The end point of the color grading |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| SAMPLER | SAMPLER | — |