Nodes/ComfyUI_BiRefNet_ll/LoadRembgByBiRefNetModel
ComfyUI Node Runs on cloud

LoadRembgByBiRefNetModel

Load BiRefNet from disk — including the old .pth checkpoints

By lldacing·Created 2 years ago·Updated about a year ago· 289
LoadRembgByBiRefNetModel
    • model
    model
    device
    use_weightfalse
    dtypefloat32

    AutoDownloadBiRefNetModel is the hand-holding loader. LoadRembgByBiRefNetModel is the one for people who already have the weights - or who want the old .pth checkpoints that the auto-download path doesn't touch.

    It does the same job: turn a model file into a BIREFNET handle for the rembg nodes. The difference is where the file comes from. Instead of a fixed dropdown of model names, this node's model dropdown is populated live from whatever .safetensors (or legacy .pth) files sit in the pack's model folder. Drop a file in, refresh, and it appears.

    How it works

    The pack registers a model folder under ComfyUI's birefnet key, defaulting to models/BiRefNet - the same folder AutoDownloadBiRefNetModel writes into, so the two loaders share one pool of files. If you've configured a birefnet path in your extra_model_paths.yaml, this node reads from there instead.

    The genuinely interesting bit is that this loader supports two model generations:

    • New .safetensors weights (General, General-HR, Matting, etc.) load into the current BiRefNet architecture. As with the auto-download node, Lite models automatically get the Swin-Tiny backbone and everything else Swin-Large.
    • Old .pth checkpoints (BiRefNet-DIS_ep580.pth, BiRefNet-ep480.pth) are detected by filename and loaded into the old architecture this pack bundles. That's the birefnet_old code path - the reason the pack's tagline is "support the use of new and old versions of BiRefNet models."

    Two optional toggles:

    • use_weight (default off) - loads pretrained Swin backbone weights alongside the model. For the modern .safetensors files you almost never need this; the released weights are complete. It exists mainly for people reproducing the old pipeline from scratch, and it means downloading an extra swin_large...pth (or swin_tiny...pth for Lite) file.
    • dtype (default float32) - switch to float16 for roughly half the VRAM and about double the speed. BiRefNet's author validated FP16 at no meaningful accuracy cost; there's no reason to stay on FP32 for a cutout.

    device is AUTO (GPU) or CPU.

    Output is a single model (BIREFNET) that plugs into RembgByBiRefNet, RembgByBiRefNetAdvanced, or GetMaskByBiRefNet.

    Install and model placement

    Standard pack install - ComfyUI Manager (search ComfyUI_BiRefNet_ll) or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/lldacing/ComfyUI_BiRefNet_ll.git
    cd ComfyUI_BiRefNet_ll
    pip install -r requirements.txt   # numpy, opencv-python, timm
    # restart ComfyUI
    

    Then drop your weights into models/BiRefNet/. If you downloaded from the ZhengPeng7 HuggingFace repos, remember the README's rename rule: model.safetensors must be renamed to something like General.safetensors - the filename is the model identifier in the dropdown.

    Where people get stuck

    • The model dropdown is empty - no files in the folder yet, or the birefnet path in your extra_model_paths.yaml points somewhere that isn't models/BiRefNet. Put a .safetensors file there and refresh the node list.
    • A .pth file loads but behaves oddly - old checkpoints expect the old preprocessing (normalization to mean 0.5, not the ImageNet-style 0.485/0.456/0.406 the new models use). The pack routes that automatically by filename, so if you renamed an old file to something that doesn't match BiRefNet-*.pth, it'll get treated as new and look wrong.
    • "Should I use this or AutoDownload?" - if you don't already have files on disk, use AutoDownloadBiRefNetModel. It downloads, names, and loads in one step. This node is for the "I keep my models in a shared folder / I want the legacy .pth" crowd.
    Categoryrembg/BiRefNet

    Inputs (4)

    NameTypeDefaultDescription
    modelCOMBO0 options:
    deviceCOMBO2 options: AUTO, CPU
    use_weightoptBOOLEANfalse
    dtypeoptCOMBOfloat322 options: float32, float16

    Outputs (1)

    NameTypeDescription
    modelBIREFNET