FlowRVS_SM_Apply_Mask
Cut the segmented subject out of your video — or erase it onto the background
- mask
- image
- image
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 (
reverseoff):subject = video × mask + background_color × (1 − mask)- the subject stays, everything else becomes the background color. reverseon: 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- theMASKout ofFlowRVS_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 anIMAGEbatch (the same tensor you fedFlowRVS_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, each0–255, all255by 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 MaskToImage → CreateVideo for the raw segmentation, and the Apply_Mask → CreateVideo 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 -
reverseis on. Flip it. - A white box around everything - the mask is probably all-ones, meaning the segmentation upstream failed (check
thresholdon the Decoder), not a bug here. - Edges look like someone cut with scissors - soften the mask in
FlowRVS_SM_Decoder(gaussian_smoothingon, raisesigmaa 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.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| mask | MASK | — | |
| image | IMAGE | — | |
| reverse | BOOLEAN | false | — |
| bg_red | INT | 2550–255 | — |
| bg_green | INT | 2550–255 | — |
| bg_blue | INT | 2550–255 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |