Nodes/ComfyUI-XJNodes/SEGS Color Match Hook
ComfyUI Node

SEGS Color Match Hook

Stop the detail pass from changing the colors

By alexjx·Created 10 months ago·Updated 4 months ago· 0
SEGS Color Match Hook
    • hook
    methodmkl
    strength1.00

    Here's a detailer annoyance you've probably blamed on the model: you run a face detail pass, the face comes out sharper, but the skin tone is now slightly off - a different cast than the rest of the image. That's not a sampler problem, it's a color-shift problem: the fresh denoise pass produced its own interpretation of the colors, and it doesn't match what was already there. XJSegsColorMatchHookProvider is the fix. It's a hook for Impact Pack's Detailer/FaceDetailer that snapshots the original crop, and after the detail pass decodes, matches the enhanced image's colors back to the original's.

    "Hook" is the important word. Impact Pack's detailers have a detailer_hook input where you can plug a DETAILER_HOOK object that gets called at specific points in the pipeline. This node produces one of those objects. The color matching runs after VAE decode and before the crop is pasted back, so what lands in the final image is the detailed version wearing the original image's colors.

    The method dropdown is where the choices matter:

    • adain - adaptive instance normalization: matches the mean and standard deviation of the color statistics. Fast, and needs no extra package.
    • mkl, hm, reinhard, mvgd, hm-mvgd-hm, hm-mkl-hm - these come from the color_matcher library and are progressively fancier statistical transfers (Monge-Kantorovitch, histogram matching, Reinhard, and combos). They can preserve more of the original's character but require that package installed.

    The interface:

    • method - default mkl; adain is the zero-dependency option.
    • strength - 0–1, default 1.0. How much of the match to blend in; lower values keep more of the detailed crop's own color.
    • Output: hook, a DETAILER_HOOK you plug into the detailer_hook input of FaceDetailer or Detailer (SEGS).

    How to install: the pack is alexjx/ComfyUI-XJNodes:

    cd ComfyUI/custom_nodes
    git clone https://github.com/alexjx/ComfyUI-XJNodes
    

    Restart ComfyUI, then find the hook providers under XJNodes/segs/hooks. For the non-adain methods you'll also need the color_matcher package - install it into ComfyUI's Python environment:

    pip install color-matcher
    

    requirements.txt for the pack is empty, so that one is on you. ComfyUI Manager can also handle the pack itself (search "ComfyUI-XJNodes").

    Real-world notes: this is a personal-use pack with no tutorial ecosystem, and the mkl default is a fine starting point - but if color-matcher isn't installed, the hook fails at the moment it runs rather than at load time. Use adain if you want zero dependencies, and remember strength exists: a full 1.0 match can flatten texture along with the color cast.

    CategoryXJNodes/segs/hooks

    Inputs (2)

    NameTypeDefaultDescription
    methodCOMBOmkl7 options: adain, mkl, hm, reinhard, mvgd, hm-mvgd-hm, +1
    strengthFLOAT1.000–1

    Outputs (1)

    NameTypeDescription
    hookDETAILER_HOOK