Nodes/BaiduMeux_Comfy Tools/Meux RMBG (BiRefNet)
ComfyUI Node

Meux RMBG (BiRefNet)

BiRefNet background removal, already wired up for you

By fchangjun·Created about a year ago·Updated 5 months ago· 4
Meux RMBG (BiRefNet)
  • image
  • image
  • mask
model_presetportrait
input_size1024
apply_masktrue
invert_maskfalse
model_override

Background removal is the one operation in this pack that isn't a chore - it's a real model. MeuxRMBG runs BiRefNet, the bilateral-reference segmentation network that pretty much replaced rembg's u2net for anything with hair, fur or tricky edges. If you've cut out a subject and seen u2net massacre the flyaways, this is the fix: BiRefNet is dramatically sharper on fine boundaries, it's MIT-licensed, and this node wraps it in a straightforward "image in, cutout + mask out" interface.

One honest note before the details: BiRefNet became native in ComfyUI in May 2026, so you may not need this node at all - core ships it now. Where this node still earns its keep is that it bundles the load/download logic for you and gives you a model_override escape hatch to point at whichever BiRefNet weights you want.

How it works

It loads the model through HuggingFace's AutoModelForImageSegmentation with the usual trust_remote_code. The resolution dance: it looks for local models first - in ComfyUI/models/BiRefNet (or birefnet), or any directory you point at with the MODEL_BASE_DIR environment variable - and only downloads from HuggingFace if nothing local is found. The default repo is ZhengPeng7/BiRefNet-portrait (overridable with MODEL_REPO), and LOCAL_ONLY=1 forces strictly-local operation.

The node resizes your image to input_size × input_size (1024 by default), runs the network, and upscales the predicted mask back to the original resolution. Note input_size is the inference resolution, and it matters: feeding a 4K photo at 1024 loses the fine edges you wanted BiRefNet for - bump it toward 2048 for large inputs, at the cost of VRAM and time. The output mask gets normalized to 0–1, then invert_mask flips it if you need the polarity swapped.

Inputs and outputs

  • image (IMAGE) - the input, can be a batch; frames are processed one at a time.
  • model_preset - a dropdown that lists locally installed BiRefNet models. With nothing local it falls back to a placeholder. In the source there are two friendly presets - a portrait matting model and the general one - but they only appear in the dropdown when those local models exist.
  • input_size - inference resolution, 256–2048 in steps of 64.
  • apply_mask - when on (default), the output image is the subject with a proper alpha channel (RGBA). When off, the RGB channels stay unmasked and the alpha channel still carries the mask, so you see the full original picture shaped by the cutout.
  • invert_mask - flips the mask.
  • model_override (optional) - a free-text field to point at any model repo ID or local directory, bypassing the preset list entirely.

Outputs: image (RGBA cutout) and mask (MASK). Wire the RGBA image into a save node, a compositor, or anything that wants a transparent PNG.

The one weird thing

The preset dropdown labels are in Chinese (人像抠图 = portrait matting, 通用抠图 = general), and they only list models that are already sitting on disk. If you want the general model and it's not local, the pragmatic path is model_override with ZhengPeng7/BiRefNet (or the -HR weights for large images). That's the same repo ID the KB's model panel recommends for most cutout work, and it's MIT, so commercial use is fine.

Installing and dependencies

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

Restart ComfyUI, or use ComfyUI Manager and search "Baidu Meux ComfyTools". This is the one node in the pack where the requirements actually earn their weight: it genuinely needs transformers, torchvision, numpy and Pillow. The model itself is a multi-hundred-MB download on first run unless you've pre-dropped the weights into models/BiRefNet.

Troubleshooting

The two things that go wrong are both visible in the console: a missing-dependency error telling you transformers/torchvision aren't installed (run the requirements), and a "model directory not found" style error in Chinese when the preset points at a local model that isn't there - which is why the README tells you to put models in ComfyUI/models/BiRefNet or add a birefnet path to extra_model_paths.yaml. And if your output subject looks hollow or the edges vanish, you're feeding it too-small an input_size for the source resolution; raise it before blaming the model.

Categoryimage/segmentation

Inputs (6)

NameTypeDefaultDescription
imageIMAGE
model_presetCOMBOportrait1 options: portrait
input_sizeINT1024256–2048
apply_maskBOOLEANtrue
invert_maskBOOLEANfalse
model_overrideoptSTRING

Outputs (2)

NameTypeDescription
imageIMAGE
maskMASK