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

LayerMask: Load BiRefNet Model(Advance)

Load BiRefNet Model — ComfyUI Node Guide

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

    This one does nothing exciting by itself - it just points at a BiRefNet checkpoint on disk and hands it to a downstream node. But it's worth understanding why it exists as a separate node instead of being baked into whichever node actually does the cutting.

    BiRefNet is the segmentation model that quietly replaced rembg's old u2net as the go-to for clean cutouts, and the reason people reach for it is hair. u2net has always been visibly wrong on flyaway strands, fur, and fabric mesh - it segments the general blob and calls it done. BiRefNet was trained with a second "reference" pass specifically aimed at fine edge detail, and that's the whole reason it spread: the difference shows up in a side-by-side without needing a benchmark to prove it. It's MIT-licensed too, so there's no commercial-use asterisk to worry about.

    Here's the mechanism: the node scans ComfyUI/models/BiRefNet/pth for .pth checkpoint files and lists whatever it finds in the model dropdown. Pick one, and it loads that checkpoint into memory, then passes it downstream as a birefnet_model object. That's the entire job - one input, one output, no image processing happens here at all.

    Inputs and outputs, the short version:

    • model - a dropdown populated from whatever .pth files you've dropped into the BiRefNet folder. There's no default because it's whatever you've installed.
    • birefnet_model (output) - a BIREFNET_MODEL object that plugs into whichever segmentation node consumes it.

    Why split the loading out at all instead of letting the matting node just load its own model? Same reason this pack does it for SAM2 too (see LoadSAM2Model): if you've got multiple nodes in your graph that need the same model, loading it once and wiring the output to all of them saves you from loading the same multi-hundred-megabyte checkpoint repeatedly. It's a small efficiency thing, but it adds up if you're doing batch work with several matting passes in one graph.

    Installing it: easiest path is ComfyUI Manager - search for "ComfyUI Layer Style Advance" and install. Manually, it's cd ComfyUI/custom_nodes && git clone https://github.com/chflame163/ComfyUI_LayerStyle_Advance, then run install_requirements.bat (portable Windows build) or pip install -r requirements.txt inside your venv, followed by repair_dependency.bat to shake loose a few finicky dependencies. Restart ComfyUI after.

    For the model itself, grab the .pth files from huggingface.co/ViperYX/BiRefNet (or the BaiduNetdisk mirror if you're in China) - specifically BiRefNet-ep480.pth, pvt_v2_b2.pth, pvt_v2_b5.pth, swin_base_patch4_window12_384_22kto1k.pth, and swin_large_patch4_window12_384_22kto1k.pth - and drop them in ComfyUI/models/BiRefNet/pth. That last folder segment matters: the loader only looks in pth, not the parent BiRefNet directory, so files sitting one level up won't show in the dropdown.

    Where people get tripped up: an empty dropdown almost always means the files landed in the wrong folder - double-check you created the pth subfolder rather than dumping checkpoints straight into models/BiRefNet. Also worth knowing: ComfyUI shipped its own native BiRefNet support in core as of May 2026, using a completely different folder (models/background_removal/) and a .safetensors file, not .pth. The two paths aren't interchangeable - a checkpoint downloaded for native support won't show up here, and vice versa. If you're already running the LayerStyle Advance family of masking nodes, stick with this loader and its pth folder rather than mixing the two setups.

    Category😺dzNodes/LayerMask

    Inputs (1)

    NameTypeDefaultDescription
    modelCOMBO0 options:

    Outputs (1)

    NameTypeDescription
    birefnet_modelBIREFNET_MODEL