Nodes/SDVN_Comfy_node/🎨 Mask Color Overlay
ComfyUI Node

🎨 Mask Color Overlay

See your mask before you pay for the sampling

By StableDiffusionVN·Created 2 years ago·Updated 4 days ago· 126
🎨 Mask Color Overlay
  • image
  • mask
  • image
◄color_hex#FF0000►
◄opacity0.50►

Plenty of bad inpainting results aren't a model problem, they're a mask problem. You painted a mask, or a YOLO detector handed you one, you burned 40 steps, and the fix landed on the wrong part of the image. The 🎨 Mask Color Overlay node exists to catch that before the sampler runs: it paints your mask over the image in a flat colour so you can see whether the region you're about to re-render is the region you meant. It generates nothing. That's the point.

It lives in StableDiffusionVN's SDVN_Comfy_node pack - the same Vietnamese group whose checkpoints turn up in the SDXL merge economy (RealVisXL credits their SDVN6-RealXL as an ingredient). The pack is a grab-bag of downloaders, merge tools, API nodes and a 🎭 Mask category holding Yolo Seg Mask, Mask Regions, Get Mask Size, Crop Inpaint and Loop Inpaint Stitch. This node is the diagnostic companion to those: when Yolo Seg Mask returns something plausible in a thumbnail, overlay it and find out whether it actually covers the face.

How it works

The mask is converted to float32, given a batch dimension if it needs one, and resized to the image's height and width with bilinear interpolation when the two don't match - so a mask from a different resolution won't error, it'll be stretched to fit. Then the hex colour becomes three floats and the blend is a plain lerp: output = image * (1 - alpha) + colour * alpha, with alpha = the mask clamped to 0–1, times opacity. Four-channel input keeps its alpha; 3-channel comes out as RGB; anything else raises.

Two things follow. The blend runs in ComfyUI's ordinary 0–1 sRGB-ish space, not linear light, so partial opacity looks duller than you'd guess - fine for "is the mask in the right place", useless for colour work. And soft mask edges ride through the lerp, so a feathered mask shows as a gradient instead of a hard line: a quick read on whether your mask blur is sane.

The inputs that matter

  • image - the base picture. Any IMAGE.
  • mask - the MASK you want to inspect. Batches don't have to match: one mask expands across a batch of images, and vice versa. Two unequal batches larger than one will raise.
  • color_hex - default #FF0000. Six hex digits, # optional, and nothing else: #F00, red or an 8-digit hex all throw Màu phải có định dạng HEX #RRGGBB at runtime, failing the run rather than quietly doing something odd. Red over skin is muddy; #00FF00 reads better on most photos.
  • opacity - 0 to 1, default 0.5. This is a multiplier on the mask, so the default gives you a translucent wash. If you want a solid fill you have to push it to 1.0, and that trips people up - at 0.5 a fully-covered mask still shows the image underneath.

One output, image: the original with colour blended through the mask. Wire it to Preview Image or Save Image. Wiring it anywhere else is the trap - feed this into a sampler or a VAE encode and you're generating from a picture with red smeared over it.

Install

ComfyUI Manager → search SDVN_Comfy_node, install, restart. Or the manual route:

cd ComfyUI/custom_nodes
git clone https://github.com/StableDiffusionVN/SDVN_Comfy_node
cd ..
pip install -r custom_nodes/SDVN_Comfy_node/requirements.txt

Heads up: the pack's __init__.py runs that same pip install itself on first startup and writes an installed.txt marker, so you may see it working through the list in the console. It also fetches aria2c on Windows and, on Linux, fires a sudo apt install fonts-jetbrains-mono. Neither matters for this node.

The requirements are chunky for a picture-blending node: openai, google-genai, gallery-dl, instaloader, googletrans-py, opencv-python, ultralytics==8.3.107, all into the same Python environment as everything else. Two things soften it: ultralytics loads lazily, only when you run Yolo Seg Mask, and this node needs nothing past torch and PIL. But a bad import in any other module still takes the whole pack down, so if 🎨 Mask Color Overlay disappears from the node list one update, suspect an unrelated dependency.

Where it goes wrong

  • "Requirement already satisfied" spam on every launch. The auto-installer re-checks on startup, one line per package. Harmless, annoying.
  • The overlay looks right and the mask is still wrong. Because the mask gets stretched to the image, a mask from a different aspect ratio will look convincing at 0.5 opacity. Resize the mask yourself first, then check.
  • Confusing it with its sibling. The pack also ships 🧩 Overlay Mask (SDVN Overlay Mask Color Image), which alpha-composites and only reads mask[0]. This node is the batch-aware one.

The honest comparison: core's Mask To Image plus Preview Image already shows you where a mask is, just not what it sits on. On a face occupying 3% of frame, that context is the whole question.

Category📂 SDVN/🎭 Mask

Inputs (4)

NameTypeDefaultDescription
imageIMAGEẢnh gốc cần phủ màu
maskMASKMask xác định vùng phủ màu
color_hexSTRING#FF0000Màu phủ dạng HEX, ví dụ #FF0000
opacityFLOAT0.500–1Độ đậm của lớp màu

Outputs (1)

NameTypeDescription
imageIMAGEẢnh gốc sau khi phủ màu theo mask.