(deforum) Color Match
Stop your animation from slowly shifting color as it drifts frame to frame
- image
- deforum_frame_data
- force_sample_image
- IMAGE
The chronic disease of frame-by-frame img2img animation is color drift. Each frame is sampled from the last, so tiny hue and brightness differences accumulate - ten seconds in, the whole scene has slowly shifted teal, or the whites have gone yellow, or the shadows have crawled toward magenta. (deforum) Color Match is the cure: it takes the current frame and regrades it to match a reference frame, using the color-coherence mode you set in the pack's ColorMatch Parameters. It's the per-frame enforcement arm of Deforum's color coherence system - the node that actually applies the fix, every frame, before the result hits the save node.
How it works
The node keeps a color_match_sample - the reference colors the animation should stay anchored to. On frame 0 it grabs the first frame as that sample (so the whole video is anchored to its own opening look, which is almost always what you want). From then on, each incoming frame is run through Deforum's maintain_colors function, which remaps the frame's colors onto the sample's using the configured color_coherence mode (HSV, LAB, RGB) - matching histograms and color distributions in that color space. The output is the regraded frame.
The force_use_sample toggle changes the anchor: flip it on (optionally feeding a specific force_sample_image) and the node stops using frame 0 and instead matches against the image you supply. That's how you lock a video to an external reference look - a still you generated earlier, a frame from a style test, whatever. If no sample is set, it gracefully passes the frame through untouched rather than crashing.
The inputs that matter
image- the current frame to regrade.deforum_frame_data- carries the frame index (so it knows when it's frame 0) and thecolor_coherencesetting from your parameters nodes.force_use_sample- default false; enable to anchor against something other than frame 0.force_sample_image- optional; the image to use as the anchor whenforce_use_sampleis on.
Output is the regraded IMAGE, wired on toward the sampler or save node.
When you need it
If your animations are short (under a couple of seconds) you may never notice drift. The longer the run, the more this node earns its place - it's the difference between a 20-second clip that holds its palette and one that slowly melts into a different movie. You'll also reach for it deliberately when you want a consistent brand look across scenes: force a sample and every scene gets graded to it. Note it depends on the color_coherence setting from (deforum) ColorMatch Parameters - if that's set to None, this node has nothing to do, so the two are a pair.
Installing it
Part of Deforum Nodes (XmYx). ComfyUI Manager → "Deforum Nodes", or:
cd ComfyUI/custom_nodes
git clone https://github.com/XmYx/deforum-comfy-nodes.git
Restart and let first-boot install.py finish (opencv-contrib-python, moviepy, numpy<2.0.0, deforum-studio backend). Python 3.10 per the README.
Where people get burned
Two things. First, expecting it to fix drift while color_coherence is None upstream - it's a no-op, and the drift you see is exactly what the setting was supposed to prevent. Second, force_use_sample with a badly chosen anchor: if your sample image has a very different exposure or white balance than the animation, every frame gets graded toward it and the video looks wrong in a new, consistent way. Pick the anchor from the same visual family as your footage. And remember LAB/HSV modes grade differently - if one makes colors oversaturated, the other may fix it.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| deforum_frame_data | DEFORUM_FRAME_DATA | — | |
| force_use_sample | BOOLEAN | false | — |
| force_sample_imageopt | IMAGE | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |