Nodes/ComfyUI_FlowRVS/FlowRVS_SM_Apply_Mask
ComfyUI Node

FlowRVS_SM_Apply_Mask

Cut the segmented subject out of your video — or erase it onto the background

By smthemex·Created 11 months ago·Updated 7 months ago· 8
FlowRVS_SM_Apply_Mask
  • mask
  • image
  • image
reversefalse
bg_red255
bg_green255
bg_blue255

This is the leaf node of the FlowRVS pack, and it's the one that turns a segmentation mask into something you can actually use: a video of the subject standing alone, or a video with the subject removed. It does zero inference and loads zero models - it's a two-tensor composite, the kind of node you'd normally call boring. But when it's the difference between "I have a mask" and "I have a usable matte", boring is the good option.

The math is dead simple. It takes the mask (values clamped to 0–1), broadcasts it to the video's shape, and mixes:

  • Default (reverse off): subject = video × mask + background_color × (1 − mask) - the subject stays, everything else becomes the background color.
  • reverse on: the subject gets replaced by the background color and everything else is kept - i.e. you erase the segmented object from the frame.

The background color defaults to white (bg_red/green/blue all 255), which is the right call for checking masks and for most green/white-plate workflows, but you can set any RGB you like per channel.

Inputs and what to wire

  • mask - the MASK out of FlowRVS_SM_Decoder. Note the mask and the image need to line up frame-for-frame; since both come from the same video and the decoder restores original dimensions, that just works.
  • image - your original video frames as an IMAGE batch (the same tensor you fed FlowRVS_SM_Cond).
  • reverse - bool, default off. Flip it to remove the subject instead of keeping it.
  • bg_red / bg_green / bg_blue - the background RGB, each 0–255, all 255 by default.

The output is image (IMAGE), which feeds a PreviewImage or a CreateVideo node. The pack's example workflow runs two branches off the same mask - a MaskToImageCreateVideo for the raw segmentation, and the Apply_MaskCreateVideo for the composited clip - so you get both the matte and the cut in one queue.

A genuinely useful pattern: run the same mask twice, once with reverse off and once with it on, and you get a subject-isolated clip and a background plate from a single pass - which is exactly the pair you'd want before feeding either one further down a pipeline.

Installing

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

Or ComfyUI Manager → search "ComfyUI_FlowRVS". This node itself has no model requirements, but the pack as a whole needs the four files the README lists (Wan DiT, FlowRVS DiT, Wan VAE, tuned_vae.pth) plus the umt5 text encoder - see the FlowRVS_SM_Model and FlowRVS_SM_VAE articles for the exact paths.

Troubleshooting

  • The subject is gone and the background is blank - reverse is on. Flip it.
  • A white box around everything - the mask is probably all-ones, meaning the segmentation upstream failed (check threshold on the Decoder), not a bug here.
  • Edges look like someone cut with scissors - soften the mask in FlowRVS_SM_Decoder (gaussian_smoothing on, raise sigma a touch) rather than trying to fix it at composite time.

One caveat: there's no feather/blur on this node, so a hard mask gives a hard cut. If you need a soft matte, do the smoothing upstream in the Decoder - that's where the pack intends you to tune.

CategoryFlowRVS_SM

Inputs (6)

NameTypeDefaultDescription
maskMASK
imageIMAGE
reverseBOOLEANfalse
bg_redINT2550–255
bg_greenINT2550–255
bg_blueINT2550–255

Outputs (1)

NameTypeDescription
imageIMAGE