Nodes/H3 Relay/H3 Relay Green Mask
ComfyUI Node

H3 Relay Green Mask

Paint the person green and let the model erase them

By akatz-ai·Created 3 months ago·Updated 10 days ago· 44
H3 Relay Green Mask
  • images
  • mask
  • IMAGE
◄expand_pixels5►

A mask is a tensor. A video model reads pixels. H3 Relay Green Mask is the one-line bridge between those two facts: it takes your per-frame mask, grows it a little, and paints the selected pixels pure green - RGB 0, 255, 0 - in an otherwise untouched copy of your footage.

That flat green slab is the signal the Person Remover LoRA was trained on. It's not a visualisation aid, it's the conditioning. Which is why you should look at it before you spend twenty minutes rendering.

Inputs

  • images - your source frames, as loaded from a video.
  • mask - one mask per frame at the same resolution. It has to be a batch matching images; feed it a single still mask or a differently-scaled one and you get a hard error rather than a silently mis-masked render.
  • expand_pixels - how far to grow the mask on each side, 0–64, default 5.

The default is 5 for a reason. Segmentation edges are tight, and a hard cutout leaves a green-free halo of the person - a shoulder, a strand of hair, the outline of a shadow - that the model then dutifully reconstructs. Growth is done with an actual max-pool dilation, so it's a proper outward expansion, not a blur. Push it higher if you keep seeing ghost edges; drop it to 0–2 when your subject is standing in front of something delicate you don't want smeared.

If the mask is empty on a frame, the frame passes through unchanged. Correct behaviour, and also the failure mode: nothing warns you that tracking dropped out for forty frames - you just get a person still standing there in the output. Preview first.

Output

Just IMAGE - the prepared green-masked source. Wire it to the Person Remover's masked_source, and wire the clean first frame separately to clean_first_frame. Those are two different things and mixing them up is a classic.

Getting the mask in the first place

The pack expects native ComfyUI SAM 3 nodes upstream: SAM3_Detect on a short text description ("man in gray shirt", not "person"), then SAM3_VideoTrack to propagate across frames. You don't need a point selector or KJ nodes; the SAM checkpoint carries its own text encoder.

Two things from the wider masking ecosystem that apply directly here. First, SAM 3's promptable segmentation is the right tool for "this specific guy", and a specific description matters - if two people match, you get two people masked. Second, the SAM 3 ComfyUI nodes need Triton, which is a genuine obstacle on Windows. If you've been fighting segmentation-node installs, that's usually why.

The cache, and why re-runs are cheap

This node is lazily evaluated and it persists its output. The prepared green-masked source is written into ComfyUI/output/__h3_removal_cache/prepared/ as a lossless tensor, keyed by a hash of the real source bytes plus the mask-graph settings you used. Re-run an unchanged workflow, or reroll a window, and SAM detection and tracking are skipped entirely - including after a ComfyUI restart. Change the source video, the target text, the tracking settings, expand_pixels, or the SAM model version, and a new prepared mask is made.

That's the good news. The bad news is those files are big, because they're full float tensors. Deleting them just means the next run prepares the mask again.

The identity hash walks the upstream graph, but only through a whitelist of node types it knows are deterministic (loaders, text encode, SAM nodes, mask utilities). Put something exotic between your video and this node and it falls back to ordinary evaluation instead of guessing - slower, but never wrong.

Install

Ships with the pack: Manager → H3 Relay, or

cd /path/to/ComfyUI/custom_nodes
git clone https://github.com/akatz-ai/h3-relay.git

Then restart. Needs ComfyUI 0.32.0+ (0.37.0 is what the removal workflow was validated against), native H3 and SAM 3 nodes, FFmpeg on PATH, and the Ref2VA/Qwen/SAM3/model files from the pack's model manifest. The Person Remover LoRA adapter's public release is still pending, so this node is currently easy to install and hard to run end-to-end.

Snags

  • Provide one aligned mask per source frame at the same resolution - mask batch count or size doesn't match the images. Resize the mask, don't resize the video after masking.
  • Green edges left in the output - bump expand_pixels, then look at the prepared preview again.
  • Background text, reflections and handshakes change - that's the whole-image nature of the edit, not the mask. Green masking steers the model; it doesn't restrict it to a region the way inpainting does.
  • The mask looks right in the node preview but the render disagrees - check which frame you're looking at. Preview cards show the window, and window boundaries are where tracking errors surface.
CategoryH3 Relay/person remover

Inputs (3)

NameTypeDefaultDescription
imagesIMAGE—
maskMASK—
expand_pixelsINT50–64—

Outputs (1)

NameTypeDescription
IMAGEIMAGE—