Nodes/TrentNodes/Vace Mask AutoComping
ComfyUI Node

Vace Mask AutoComping

Stop hand-building Wan VACE's gray inpaint regions

By TrentHunter82·Created 9 months ago·Updated 4 days ago· 36
Vace Mask AutoComping
  • images
  • masks
  • images
  • masks
expand_pixels0
gray_value0.50

Wan VACE has a specific and slightly weird expectation: for inpainting-style edits, the area you want regenerated gets painted solid gray over the original frame, and that gray-over-original composite is what the model actually sees. Doing that by hand - mask, fill, composite - is fiddly and easy to get wrong. Vace Mask AutoComping is the node that does it for you: feed it an image batch and a mask batch, and it returns the video with solid gray overlaid on the masked regions, plus a matching clean binary mask.

It saves you from the manual gray-over-original setup that VACE expects, which is exactly the chore the README promises to kill. If you're doing VACE object removal, region swap, or targeted regeneration with SAM-generated masks, this is the prep step you no longer write by hand.

How it works

Required inputs:

  • images - the image or image batch to composite gray over
  • masks - the mask or mask batch defining the regions to cover (white = cover)

Two optional controls:

  • expand_pixels - grows the mask outward by this many pixels before compositing, with a hard edge and no feather. Use it to widen the inpaint region so the model has room to work around the target's edges.
  • gray_value - the gray level for masked areas. Default 0.5, which the tooltip notes matches VACE's default filler. That default matching is the kind of detail that saves you a mystery-color artifact later.

The node handles the two annoyances that make hand-rolled versions brittle: single-mask-to-batch broadcast (one mask applies to all frames) and automatic spatial resizing to match the images. Mask dilation is GPU-accelerated.

Outputs: images (the originals with gray composited over masked areas) and masks (a clean binary mask - white where gray was applied, black elsewhere - so the mask and the composite stay in sync downstream).

The workflow it slots into

The README's framing is the canonical path: feed in an image batch and a mask batch (e.g. from SAM3), and it produces the grayed composite plus a matching clean mask. The keyframe-style VACE workflows in this pack's Trent/Keyframes category (Wan Vace Keyframe Builder) then consume the result. You get the exact "mask defines what gets regenerated" contract without the four-node manual composite.

Gotchas

  • expand_pixels is a hard edge with no feather, on purpose - VACE wants a clean boundary for the inpaint region, so don't expect soft feathered growth here. If you want feathering, do it on the mask before it arrives.
  • The gray is replacing the masked region, not overlaying with transparency. The original content under the mask is gone from the composite - that's the point, but it means you must keep the original images around if you need them for anything else.
  • Default gray_value 0.5 matches VACE's filler; if you've seen washed-out or wrong-hued inpaint results, the first suspect is a gray value that drifted off 0.5 somewhere in your manual composite. This node makes that a non-issue.

Install

Part of TrentNodes (TrentHunter82/TrentNodes):

# ComfyUI Manager: search "Trent Nodes"

# or:
cd ComfyUI/custom_nodes
git clone https://github.com/TrentHunter82/TrentNodes.git
cd TrentNodes && pip install -r requirements.txt

No model downloads - the heavy lifting (Wan VACE itself, SAM3) is upstream of this node, not inside it. It's a pure compositing utility, and it's the kind of node that makes you wonder why you ever built the manual version.

CategoryTrent/Keyframes

Inputs (4)

NameTypeDefaultDescription
imagesIMAGEInput image or image batch to composite gray over masked regions
masksMASKMask or mask batch defining regions to cover with gray (white = cover)
expand_pixelsoptINT00–256Expand mask outward by this many pixels before compositing (hard edge, no feather)
gray_valueoptFLOAT0.500–1Gray level for masked areas (0.5 = mid gray, matches VACE default filler)

Outputs (2)

NameTypeDescription
imagesIMAGEOriginal images with solid gray composited over masked areas
masksMASKClean binary mask: white (1) where gray was applied, black (0) elsewhere