Nodes/ComfyUI_BiRefNet_ll/AutoDownloadBiRefNetModel
ComfyUI Node Runs on cloud

AutoDownloadBiRefNetModel

The node that downloads BiRefNet so you don't have to

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

    Most ComfyUI model loaders expect you to have already tracked down a weights file and dropped it in a folder. AutoDownloadBiRefNetModel is the lazy one: pick a model from a dropdown, run the workflow, and the first time it loads it downloads the weights from HuggingFace into models/BiRefNet and carries on. No hunting links, no renaming files, no "which repo is this again?" - at least when your network behaves.

    It's the entry point for the whole ComfyUI_BiRefNet_ll pack. You can't do any background removal until some node produces a BIREFNET handle, and this is the fastest way to get one.

    How it works

    Choose a model_name and the node checks whether <model_name>.safetensors exists in models/BiRefNet. Missing? It pulls model.safetensors from the matching ZhengPeng7/... HuggingFace repo via torch.hub, saves it under the friendly name, and loads it. Already there? It just loads it - subsequent runs are instant.

    The node also picks the right backbone automatically. The Lite models (General-Lite, General-Lite-2K, Matting-Lite) get the Swin-Tiny backbone; everything else gets Swin-Large. You never see this - it just means the small weights load fast and the big ones are accurate.

    device is AUTO (your GPU) or CPU for machines without CUDA. dtype defaults to float32; flip it to float16 unless you have a specific reason not to - half the VRAM, roughly twice the speed, and the author of BiRefNet validated FP16 at no meaningful accuracy cost. There is no reason to run FP32 for a background cutout.

    Picking a model

    The dropdown has fifteen entries and they are not interchangeable:

    • General - the default, Swin-Large trained at 1024. Start here.
    • General-HR - trained at 2048. Reach for it when your input is above about 1500px, or the 1024 model downsizes internally and throws away the edge detail you wanted.
    • General-Lite / General-Lite-2K - Swin-Tiny, for weak GPUs. Trade accuracy for speed.
    • Portrait - specialist for people.
    • Matting / Matting-HR / Matting-Lite - predict fractional alpha instead of a hard mask. This is what you want for veils, glass, smoke and motion blur, where a binary mask is the wrong output.
    • DIS / HRSOD / COD / DIS-TR_TEs / General-legacy / General-reso_512 / General-dynamic - mostly paper-benchmark weights and specialisations. Don't reach for these to cut out a photo; General beats them on real images.

    Output is a single model (BIREFNET), which wires straight into RembgByBiRefNet, RembgByBiRefNetAdvanced, or GetMaskByBiRefNet.

    Install

    Same pack, same three steps:

    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
    

    ComfyUI Manager users can just search ComfyUI_BiRefNet_ll and install from there.

    Where people get stuck

    • First run "hangs" - it isn't hanging, it's downloading roughly a gigabyte from HuggingFace. Watch the console; the progress is there. On a slow or geo-blocked connection it can look frozen.
    • Download fails - the fallback is manual: grab the file from the ZhengPeng7/<repo>/resolve/main/model.safetensors link in the README and save it as General.safetensors (rename it!) in models/BiRefNet. The naming is the model selection, so don't skip the rename.
    • Missing folder - the pack creates models/BiRefNet for you, but if you previously had another BiRefNet pack the folder key can point somewhere else. Check that a birefnet path in extra_model_paths.yaml isn't redirecting the download somewhere you're not looking.

    If you'd rather manage the files yourself, LoadRembgByBiRefNetModel is the sibling node that reads whatever you've already placed in that folder - including the older .pth checkpoints this pack still supports.

    Categoryimage/BiRefNet

    Inputs (3)

    NameTypeDefaultDescription
    model_nameCOMBO15 options: General, General-HR, Matting-HR, General-Lite, General-Lite-2K, General-reso_512, +9
    deviceCOMBO2 options: AUTO, CPU
    dtypeoptCOMBOfloat322 options: float32, float16

    Outputs (1)

    NameTypeDescription
    modelBIREFNET