Nodes/ComfyUI_LayerStyle_Advance/LayerMask: Load BiRefNet Model V2(Advance)
ComfyUI Node Runs on cloud

LayerMask: Load BiRefNet Model V2(Advance)

Load BiRefNet Model V2 — pick BiRefNet or RMBG-2.0, then hand it off

By chflame163·Created 2 years ago·Updated 4 months ago· 696
LayerMask: Load BiRefNet Model V2(Advance)
    • birefnet_model
    versionBiRefNet-General

    This is the loader half of the pack's BiRefNet setup - it doesn't do any masking itself, it just picks a checkpoint and hands a birefnet_model handle to LayerMask: BiRefNet Ultra V2. It exists as a separate node specifically so you're not reloading the model every time you run a cutout in a bigger graph; load once, wire the output wherever you need it. The "V2" here refers to a PR contributed by jimlee2048 that added support for loading RMBG-2.0 alongside the original BiRefNet weights, which is the whole reason this loader exists as distinct from the original LoadBiRefNetModel.

    There's one input: version, an enum with two choices - BiRefNet-General (the default, and what most people mean when they just say "BiRefNet") or RMBG-2.0. Both are segmentation models aimed at the same job - cutting a clean subject mask, especially on hard edges like hair and fur - and both are worth having on hand because neither one wins every comparison; testing your own trickiest few images against each before committing to one is a more reliable way to pick than trusting either one's reputation. BiRefNet-General is trained at 1024×1024 and is what ComfyUI's own ecosystem has converged on as the default recommendation; RMBG-2.0 is BRIA AI's competing model and a common alternative worth trying side by side. Output is birefnet_model, feeding straight into the Ultra V2 masking node.

    Install via ComfyUI Manager (search "ComfyUI Layer Style Advance") or git clone https://github.com/chflame163/ComfyUI_LayerStyle_Advance into custom_nodes/, restart, run the requirements installer. Model files depend on which version you plan to use: for BiRefNet-General, grab BiRefNet-general-epoch_244.pth and drop it in ComfyUI/Models/BiRefNet/pth (note the capitalized "Models" - matters on Linux/Mac). For RMBG-2.0, download the model files from huggingface.co/briaai/RMBG-2.0 and copy them into ComfyUI/models/BiRefNet/RMBG-2.0. Both are also bundled in chflame163's combined HuggingFace model repo if you'd rather pull everything from one source. You can drop additional BiRefNet .pth checkpoints into the same pth folder beyond just the general one - the loader lists whatever it finds there.

    This node itself is lightweight and rarely the thing that breaks - most of the real troubleshooting lives downstream in the Ultra V2 masking node once the model's actually running (edge-refinement dependency issues, VRAM on large images, and so on). The one thing worth double-checking here specifically is the folder path: because the general-weights path uses a capitalized Models/BiRefNet/pth while nearly everything else in ComfyUI uses lowercase models/, it's an easy typo to make on case-sensitive filesystems, and the symptom is simply an empty dropdown in this node rather than any error message - if version shows no checkpoints to pick from, that's almost always a path-casing mismatch rather than a missing download.

    It's also worth being deliberate about which of the two you actually load, rather than defaulting to whichever one loads first. BiRefNet is MIT-licensed with no commercial-use restriction and has the deeper model family behind it - separate HR and matting variants exist upstream if you ever need to swap checkpoints for very large images or genuinely semi-transparent subjects. RMBG-2.0 is worth keeping around specifically as a second opinion: on any given image the two don't always agree on the hardest edges, and having both loaded means you can compare rather than assume one is strictly better. Since this node only loads whichever version you pick per run, switching between them for a quick comparison costs you a reload, not a reinstall.

    Category😺dzNodes/LayerMask

    Inputs (1)

    NameTypeDefaultDescription
    versionCOMBOBiRefNet-General2 options: BiRefNet-General, RMBG-2.0

    Outputs (1)

    NameTypeDescription
    birefnet_modelBIREFNET_MODEL