Garment Recolor
Post-generation garment recoloring nodes for VTO pipelines. LAB-colorspace recolor with pattern/shading preservation, plus auto-harmony palette remapping for multi-color prints.
ComfyUI Garment Recolor
Post-generation garment recoloring nodes for ComfyUI, built for virtual try-on (VTO) pipelines. Operates in LAB colorspace to preserve fabric shading, folds, and pattern detail instead of flattening the garment to a flat hue-shifted color.
No diffusion pass required — this runs as a fast, deterministic image-processing step after your VTO generation, so it's cheap to run repeatedly (e.g. for live color preview in a frontend) without hitting your GPU pipeline again.
Nodes
Garment Recolor (LAB, hex/RGB) — GarmentRecolorLAB
Recolors a masked garment region to a single target hex/RGB color.
| Input | Type | Description |
|---|---|---|
| image | IMAGE | Garment/VTO output image |
| mask | MASK | Garment region (white = recolor, black = untouched) |
| hex_color | STRING | Target color, e.g. #3A6B4C |
| mode | flat / preserve_pattern | flat overwrites the whole region to one uniform color (best for solid-color garments). preserve_pattern shifts each pixel's color by a delta relative to the region's average, keeping pattern contrast intact (best for prints, stripes, multi-tone fabrics). |
| saturation_boost | FLOAT (0.5–1.8) | Scales chroma/vividness of the result |
| light_garment_fix | BOOLEAN | Prevents white/pastel garments from staying washed out after recolor |
Garment Palette Remap (auto-harmony) — GarmentPaletteRemap
For patterned/multi-color garments. Changes the dominant/background color and automatically derives new values for the remaining pattern colors by preserving their original hue/chroma relationship to the base color — so a hue rotation applied to the base is applied consistently across the whole palette, keeping the print's original color harmony intact rather than flattening it to one color or leaving secondary colors untouched.
| Input | Type | Description |
|---|---|---|
| image | IMAGE | Garment/VTO output image |
| mask | MASK | Garment region |
| new_base_hex | STRING | Target color for the dominant/background color |
| num_colors | INT (2–8) | How many distinct colors to detect via k-means clustering |
| harmony_strength | FLOAT (0.0–1.5) | How strongly secondary colors follow the base color's shift. 1.0 = fully derived, 0.0 = secondary colors untouched |
| saturation_boost | FLOAT (0.5–1.8) | Scales chroma/vividness of the whole derived palette |
| light_garment_fix | BOOLEAN | Same fix as above, applied per-cluster |
Handles near-neutral base colors (white/cream backgrounds) as a special case: since a neutral color has no well-defined hue to "rotate," secondary colors are instead pulled proportionally toward the new base hue, which produces a coherent analogous palette instead of unstable/harsh results.
Installation
Clone into your ComfyUI custom_nodes directory:
cd ComfyUI/custom_nodes
git clone https://github.com/wama-rohan/comfyui-garment-recolor.git
Or install via ComfyUI Manager once listed, or download this repo as a ZIP and extract into custom_nodes/.
Restart ComfyUI (or ComfyUI Desktop — fully quit and relaunch, not just refresh) after installing.
Requirements
opencv-python
numpy
torch
torch and numpy are already part of any ComfyUI environment. opencv-python is the only dependency you may need to add:
pip install opencv-python
Color picker widget
Both nodes' hex-color inputs render as a native color-picker swatch in the UI (instead of a plain text box) via the included JS extension in web/garment_recolor.js, auto-loaded by ComfyUI.
Typical pipeline placement
Place these nodes after your VTON generation step (e.g. after VAEDecode) and before any background-swap/compositing stage, using a garment-only segmentation mask (not a full-person cutout mask):
[VTON KSampler] → [VAEDecode] → [GarmentRecolorLAB or GarmentPaletteRemap] → [downstream: background swap / SaveImage]
Notes / limitations
GarmentPaletteRemap's color clustering is k-means on the LAB a/b plane — works well on clean, distinct pattern colors; noisier on heavily textured or gradient-heavy prints where cluster boundaries are less clean.- Both nodes operate purely on pixel data (no regeneration), so extremely fine multi-color patterns (e.g. a print with 8+ genuinely distinct hues) may need a higher
num_colorsand manual tuning per garment. - Not intended for selectively recoloring one specific pattern element while leaving others literally untouched —
harmony_strengthlets you dial how much secondary colors move, but true independent per-color editing would need separate masks per color region.
License
Apache 2.0