Nodes/ComfyUI_FlowRVS/FlowRVS_SM_Decoder
ComfyUI Node

FlowRVS_SM_Decoder

Blobby mask latents in, clean per-frame masks out — meet the cleanup crew

By smthemex·Created 11 months ago·Updated 7 months ago· 8
FlowRVS_SM_Decoder
  • cond
  • vae
  • mask
threshold0.5
morphologicaltrue
kernel_size3
connected_componentstrue
min_area_ratio0.010
gaussian_smoothingtrue
sigma1.0
shrink_pixels0
shrink_method

Every segmentation pipeline has a moment where the model hands you a probability map and somebody has to decide what counts as "yes". FlowRVS_SM_Decoder is that moment, and it's where most of the fiddly widgets on this pack live - nine of them, on a node that looks trivial at first glance. The good news: the defaults are right for a first run, and each knob does one obvious thing.

What it does, mechanically: takes the mask latents from the sampler, decodes them with the tuned mask VAE, resizes back to your video's original resolution, pushes the result through a sigmoid, and then binarizes it. Everything after that is cleanup - the exact same bag of post-processing tricks that image-masking tooling has used for years, applied frame by frame.

The inputs that matter

  • cond - the dict from FlowRVS_SM_KSampler. This carries the latents and the original size/frame-count info, so the output mask comes back at exactly your video's dimensions and length.
  • vae - from FlowRVS_SM_VAE (same node that fed the Cond step).
  • threshold (default 0.5) - the binarization cutoff. Raise it (up to 1) to get more conservative masks; lower it (min 0.1) to grab more. If the object you want keeps coming out partially hollow, this is the first knob to touch.
  • morphological (default on) + kernel_size (default 3) - runs an open-then-close-then-dilate. Kills specks, fills small holes. Leave it on.
  • connected_components (default on) + min_area_ratio (default 0.01) - keeps only blobs at least 0.01× the total mask area. This is your stray-noise killer: if you're getting one correct mask plus a persistent floating speck, raise min_area_ratio and the speck disappears.
  • gaussian_smoothing (default on) + sigma (default 1) - softens the mask edges so your composite doesn't show a pixel-hard cut.
  • shrink_pixels (default 0) + shrink_method (uniform / distance) - erodes the mask inward by N pixels. The author's own note calls this "mask center shrink". Set it when FlowRVS's mask overhangs the object - common with thin objects or motion blur - to pull the edge back onto the subject. distance shrinks proportional to distance from the boundary, uniform erodes everywhere.

The output is a MASK (one per frame, T×H×W), which wires into a MaskToImageCreateVideo to see the raw segmentation, or straight into FlowRVS_SM_Apply_Mask to composite onto your video.

Installing

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

ComfyUI Manager works too - search "ComfyUI_FlowRVS". The model files are the shared pack set: Wan DiT + FlowRVS DiT, Wan diffusers VAE + tuned_vae.pth, umt5 text encoder - all spelled out in the README and in the FlowRVS_SM_Model / FlowRVS_SM_VAE articles.

Troubleshooting

  • Everything comes out pure white or pure black - check threshold, and make sure cond actually came from the pack's KSampler (a stock node upstream means the dict is malformed).
  • A clean subject mask plus one stubborn floating blob - raise min_area_ratio; that's exactly what it's for.
  • Mask edges hang outside the object - raise shrink_pixels to 2-4 and try both shrink_methods; distance is usually gentler on thin parts like limbs.
  • Mask is shorter than your video - the frame padding from the Cond step gets trimmed here, so a couple of frames' worth of edge can feel "missing" if your clip length wasn't 4n+1. Not a bug; it's the VAE's 4× temporal compression doing its job.

One honest take: this node is more capable than it needs to be for a research pack, and that's a good thing - the morphological and connected-components stages are the difference between "usable as a demo" and "usable as a matte you'd actually build a workflow on."

CategoryFlowRVS_SM

Inputs (11)

NameTypeDefaultDescription
condCONDITIONING
vaeVAE
thresholdFLOAT0.50.1–1
morphologicalBOOLEANtrue
kernel_sizeINT31–10
connected_componentsBOOLEANtrue
min_area_ratioFLOAT0.0100.001–0.1
gaussian_smoothingBOOLEANtrue
sigmaFLOAT1.00.1–5
shrink_pixelsINT00–256
shrink_methodCOMBO2 options: uniform, distance

Outputs (1)

NameTypeDescription
maskMASK