Nodes/ComfyUI-BiRefNet-ZHO/🧹BiRefNet Model Loader
ComfyUI Node

🧹BiRefNet Model Loader

Load BiRefNet Once, Stop Paying For It Every Frame

By ZHO-ZHO-ZHO·Created 2 years ago·Updated 2 years ago· 407
🧹BiRefNet Model Loader
    • birefnetmodel
    birefnet_model

    The 🧹BiRefNet Model Loader is the unglamorous half of ZHO's BiRefNet pack, and it's the half that makes the other half fast. Its whole job is to load one BiRefNet segmentation checkpoint into the graph a single time, hand it to the 🧹BiRefNet node, and then never load it again. If you've ever run a batch of cutouts where the first image takes ten seconds and the rest fly, you already know why this node exists: reading a few gigabytes of weights off disk and shoving them into a Swin Transformer is the expensive part. Do it once per graph run instead of once per image and you've just removed most of the wall time from any big batch or video job.

    That model/processing split is deliberate, and it's ZHO's house style - he built the same two-node design into his BRIA RMBG pack. Load the network, cache it in the graph, and let as many downstream runs as you want share it. It also means the loader only ever runs once even if you re-execute the queue, because nothing upstream of it has changed.

    How it works

    Under the hood the loader is honest about what it does. The birefnet_model dropdown lists whatever checkpoint files it finds in your ComfyUI/models/BiRefNet folder, then torch.load reads the state dict, strips the _orig_mod. prefix that the official repo's exported checkpoints carry, and loads it into the BiRefNet architecture that's vendored inside the pack itself. Then net.eval() and it's returned down the wire as a BRNMODEL object. If you've loaded a ComfyUI checkpoint node before, this is the same shape of thing - a node that exists only to hand something big to the next node.

    The one input and the one output

    There's nothing to tune here, which is the point:

    • birefnet_model - a dropdown of every .pth in models/BiRefNet. Pick the weights you want, typically birefnet-general.pth. One file is enough; the README asks for all six, but the dropdown is happy with whatever's in the folder.
    • birefnetmodel (type BRNMODEL) - the loaded network. This is the only output, and it wires straight into the 🧹BiRefNet node's birefnetmodel input. Nothing else accepts it.

    Install

    Same story as the rest of the pack. Either install through ComfyUI Manager (search for BiRefNet-ZHO) or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/ZHO-ZHO-ZHO/ComfyUI-BiRefNet-ZHO.git
    cd ComfyUI-BiRefNet-ZHO
    pip install -r requirements.txt   # the only dependency is timm
    

    Then restart ComfyUI. timm matters - the vendored architecture imports it for the Swin backbone, and it's the thing that's missing when this node fails to register. The checkpoints come from the HuggingFace repo the README links (ViperYX/BiRefNet); drop them into ComfyUI/models/BiRefNet and restart so the dropdown sees them. If the folder doesn't exist, make it.

    Gotchas

    The dropdown only lists files already sitting in models/BiRefNet - a fresh install shows nothing until you've downloaded weights. And budget VRAM: the loader doesn't force FP16, so at 1024² you're looking at a few gigabytes for the Swin-Large backbone (roughly 4.8GB at FP32 by the published numbers). That's the same cost as any BiRefNet implementation, but it's worth knowing before you stack it next to everything else you have resident.

    One honest caveat this pack inherits: the companion node hardcodes a 1024×1024 internal resize, so loading the 2048 HR weights here buys you nothing extra - you're still feeding it 1024. For very large inputs the HR-capable paths (ComfyUI-RMBG, or the native BiRefNet ComfyUI added in May 2026) are the better bet. If you're just cutting out typical photos, this loader plus the general checkpoint is plenty, and the whole pack is famously the node stack inside the most-upvoted dedicated background-removal workflow around - people chain it against InspyrenetRembg to compare on their own images rather than trust a leaderboard that doesn't exist.

    Category🧹BiRefNet

    Inputs (1)

    NameTypeDefaultDescription
    birefnet_modelCOMBO0 options:

    Outputs (1)

    NameTypeDescription
    birefnetmodelBRNMODEL