Nodes/ComfyUI-RMBG/VRMBG (Video Background Removal)
ComfyUI Node Runs on cloud

VRMBG (Video Background Removal)

Video background removal where the edges stop boiling

By 1038lab·Created 2 years ago·Updated 22 days ago· 2,226
VRMBG (Video Background Removal)
  • images
  • background_color
  • IMAGE
  • MASK
  • MASK_IMAGE
◄reset_statetrue►
◄mask_blur0►
◄mask_offset0►
◄invert_outputfalse►
◄unload_modelfalse►
◄backgroundAlpha►

Here's the thing nobody tells you before your first video matting graph: run an image background remover on every frame of a clip and it works. Looks great on any single frame. Play it back and the outline crawls and shimmers like it's drawn in wet ink, because each frame was segmented in total ignorance of the one before it. A mask that wobbles a pixel per frame is more distracting than a bad mask that holds still.

VRMBG-3.0 is BRIA's fix for that, and this node wraps it. As of October 2026 it's brand new and largely undiscussed, so what follows is from the source rather than from consensus.

What's actually different

Every other node in this pack treats images as N independent images. This one treats the batch as a sequence, in order, and it's built for that. VRMBG is an autoregressive temporal matting model from BRIA AI - the same house that made RMBG-2.0. Between frames it carries a state forward, so frame 200 knows what the foreground looked like at frame 199. That's where the flicker reduction comes from, and it also means the output is fractional alpha rather than a hard cut - so a soft edge, hair in motion, and the blurred boundary on a fast pan have somewhere to live.

How it works, mechanically

Worth knowing, because it explains every gotcha below. The model doesn't take one RGB image. It takes six channels: the current frame, plus the previous frame multiplied by its own predicted alpha - a "temporal prior". At the start of a clip that prior is zeroed tensors of size 1024×1024, which is why the very first frame is the weakest one in any sequence.

Inference happens at 1024×1024 whatever your source is; the alpha is resized back to native. The state - previous RGB and previous alpha - lives on the node instance in Python memory, not in the graph. reset_state clears it, and its default of true is correct for one self-contained clip.

That design has one consequence you'll hit: the state outlives a single run. Execute the graph twice with reset_state: false and the second run's first frame is conditioned on the previous run's last frame. Sometimes that's exactly what you want - feeding consecutive chunks of a long clip - and sometimes it seeds your new subject's opening frame with a ghost of the old one.

Inputs

images is the whole required story: a batch of consecutive frames, in order. If you're coming from video, that's a Load Video / VHS node output, already ordered.

  • reset_state - true for a standalone clip, false only when chaining chunks of the same shot. This is the one setting people get wrong.
  • background / background_color - Alpha for a transparent cutout, Color to burn in a solid backdrop. If you're compositing anyway, keep Alpha.
  • mask_blur / mask_offset / invert_output - the usual trio. A frame or two of Gaussian blur hides residual jitter better than nothing.
  • unload_model - frees the weights after execution. It also wipes the temporal state, which is a second way to get the reset behaviour if you're chaining runs.

Outputs

  • IMAGE - the cutout or composite, one frame per input frame.
  • MASK - alpha per frame. This is what you feed into a compositing or encode path.
  • MASK_IMAGE - the mask rendered as grey RGB, for eyeballing a strip of frames at once. Not a mask socket.

Then VHS_VideoCombine or Create Video → Save Video. If the matte looks good as stills and bad in motion, matte the same clip frame-by-frame through a still remover and compare - that's how you see what the temporal conditioning buys you.

Install

The node ships with the pack: ComfyUI Manager, search ComfyUI-RMBG, or:

cd ComfyUI/custom_nodes
git clone https://github.com/1038lab/ComfyUI-RMBG
./ComfyUI/python_embeded/python -m pip install -r ComfyUI-RMBG/requirements.txt

The model does not auto-download. Every other model in this pack fetches itself on first use; VRMBG-3.0 is deliberately excluded because of BRIA's licence terms, and the node will refuse to run rather than go get it. Download four files from briaai/VRMBG-3.0 - config.json, model.safetensors, model.py, vrmbg3_config.py - and put all four in:

ComfyUI/models/RMBG/VRMBG-3.0/

All four, including the two Python files. The node loads the model with trust_remote_code from that folder, so a missing .py is a load failure and not a partial success.

Troubleshooting

FileNotFoundError listing files you thought you downloaded. The error names exactly what's missing and the folder it expects. Usually it's model.py or vrmbg3_config.py - people grab the safetensors and stop. Also check you made VRMBG-3.0 a subfolder; loose files in models/RMBG/ don't count.

The first frame is worse than the rest. Expected. The temporal prior starts empty, so frame one is effectively being matted blind. If it bothers you, lead with a frame that's easy and trim it in the edit.

Frame one of a re-run has a phantom subject. Stale state. Set reset_state: true or turn on unload_model.

Out-of-order frames produce garbage. It happens when a batch gets sorted as strings (frame_10 before frame_2). Fix the numbering on the way in.

Category🧪AILab/🧽RMBG

Inputs (8)

NameTypeDefaultDescription
imagesIMAGEBatch of consecutive video frames [B, H, W, C] for temporal background removal.
reset_stateoptBOOLEANtrueReset temporal prior state at the beginning of this batch. Keep True for standalone clips, or False when feeding consecutive chunks.
mask_bluroptINT00–64Gaussian blur radius for softening mask edges.
mask_offsetoptINT0-64–64Expand (positive) or shrink (negative) the mask boundary in pixels.
invert_outputoptBOOLEANfalseInvert the output mask.
unload_modeloptBOOLEANfalseUnload model weights from VRAM immediately after execution.
backgroundoptCOMBOAlphaOutput format: Alpha for transparent cutout, or Color to composite against solid background.
background_coloroptCOLORCODE#222222Hex background color used when background mode is set to Color.

Outputs (3)

NameTypeDescription
IMAGEIMAGE—
MASKMASK—
MASK_IMAGEIMAGE—