🔥BiRefNet_onnx
The ONNX path
- image
- image
- mask
If 🔥BiRefNet_Lite is the pack's workhorse, 🔥BiRefNet_onnx is the one for machines where the full torch/transformers stack is the problem. It runs the same BiRefNet cutout model, exported to ONNX and executed through onnxruntime. Its default device is CPU, and it's the node you reach for on older hardware, headless boxes, or when you just want the cutout without dragging the whole deep-learning toolchain through the setup.
The trade is real, so say it up front: ONNX here is about portability, not speed. BiRefNet's author measured the ONNX export at roughly 90% slower than the torch path on the Swin-Large weights. You pick this node because it's the one that runs, not because it's the one that's fast.
How it works
Behind the scenes it's an onnxruntime InferenceSession wrapped in a rembg-style session class. The model files come from the danielgatis/rembg releases - and contrary to what the README suggests about placing files yourself, the code auto-downloads the right .onnx into models/birefnet on first run via pooch, checksum-verified. So the practical flow is: pick a model name, run the node, let it fetch, done.
The model_name enum is where you choose your weights, and there are seven: birefnet-general (default), birefnet-general-lite, birefnet-portrait, birefnet-cod, birefnet-dis, birefnet-hrsod, birefnet-massive. These are the same academic task weights rembg bundles - the general one is the everyday pick, general-lite is the light tier for constrained machines, portrait is the person specialist.
Inputs and outputs
- image - your IMAGE tensor.
- device -
cpu(default) orcuda. CUDA needs theonnxruntime-gpupackage; without it the provider list silently falls back to CPU, which catches people out. - model_name - the seven-way pick above.
- cutout_func -
putalpha(default),naive, oralpha_matting, with the threealpha_matting_*thresholds (foreground_threshold240,background_threshold10,erode_size10) that refine the trimap when matting.
Note what's not here: there's no mask_precision_threshold and no cached flag on this node. The mask output is the soft grayscale mask, unbinarized. And the caching logic in the source is commented out - a fresh InferenceSession is built on every run, so each queue pays model-loading time. Fine for occasional cutouts, annoying for batch.
Outputs are the same pair as the rest of the pack: image (RGBA cutout) and mask.
Installing it
Same pack install as the siblings - ComfyUI Manager, search "ComfyUI-BiRefNet-Super", or:
cd ComfyUI/custom_nodes
git clone https://github.com/rubi-du/ComfyUI-BiRefNet-Super.git
cd ComfyUI-BiRefNet-Super
pip install -r requirements.txt
# restart ComfyUI
The requirements install both onnxruntime and onnxruntime-gpu. Having both can confuse provider selection, so if you only need CPU, installing just the pack's requirements is fine - just know that the cuda device option will land on CPU unless the GPU runtime is actually present. If you'd rather place the model yourself, drop birefnet-general.onnx (or whichever you picked) into ComfyUI/models/birefnet/ and the node will use it.
Honest verdict: for most people on a normal GPU, the torch nodes in this pack are faster and this one is a fallback. For CPU-only laptops, containers, or anyone who's tired of transformers dependency roulette, the ONNX path is a genuinely decent way to get BiRefNet-quality cutouts. Just don't expect a speed prize - it's the runs-anywhere node, not the fast one.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| device | COMBO | cpu | 2 options: cpu, cuda |
| model_name | COMBO | birefnet-general | 7 options: birefnet-general, birefnet-general-lite, birefnet-portrait, birefnet-cod, birefnet-dis, birefnet-hrsod, +1 |
| cutout_func | COMBO | putalpha | 3 options: putalpha, naive, alpha_matting |
| alpha_matting_foreground_threshold | INT | 240 | — |
| alpha_matting_background_threshold | INT | 10 | — |
| alpha_matting_erode_size | INT | 10 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |