BiRefNet Matting
The hair-saving cutout, minus the model download
- image
- image
BiRefNet is the default background-removal model of this ecosystem - the one ComfyUI itself ships in core - and this node runs its matting variant on Runware's cloud. The one-line pitch: feed it an image, get back the subject cut out, with the hair and edges that make rembg's old u2net give up and cry.
The distinction in the variant name matters more than people think. A plain BiRefNet segmentation model labels every pixel foreground or background - a hard mask, which is structurally wrong for a veil, a wine glass, or flyaway hair. The matting weights predict fractional alpha instead: how transparent each edge pixel should be. A cutout that looks clean against grey and falls apart against a coloured background is a segmentation model being asked to do a matting job. This node is the one that actually does it.
The inputs
The required set is a single socket: image (IMAGE). That's the whole job.
Everything else is the standard pack block - outputFormat (JPG default, plus PNG and WEBP) and outputQuality (default 95), with the ttl group off by default. One practical warning hidden in that default: JPG has no alpha channel. If you want the transparency your matting model just worked so hard to predict, set outputFormat to PNG - otherwise the cloud bakes the cutout onto whatever background (or white) and the alpha is gone. This is the single most common way people undo their own work here.
Output is a native image (IMAGE). Note it's an image, not a MASK - you get the matted result back, ready to composite or drop onto a new background.
How it works
Pack-standard mechanism: your image is encoded to a PNG data URI, sent to Runware, the matting model runs on their GPUs, and the result is downloaded back into your graph. No weights to fetch, no ONNX to babysit, no VRAM math - the model's ~4GB footprint lives on their side. Each run's cost shows on the title bar.
Install and gotchas
Install the pack once - ComfyUI Manager, search Runware - or git clone https://github.com/Runware/ComfyUI-Runware into custom_nodes and pip install -r requirements.txt, then restart and set a Runware API key (Settings → Runware API key, RUNWARE_API_KEY, or runware auth login).
The gotchas are few and specific. Set PNG output if you need the transparency. Feed it a clean, well-lit subject - matting survives difficult edges, not a 3-megapixel thumbnail. And remember this is a paid API, so it's not the tool for batch-cutting 10,000 catalog photos; for that, the same BiRefNet runs free in core ComfyUI if you have a GPU. What this node buys you is the exact same quality with zero setup and zero disk - the right call for occasional cutouts on a machine that can't run the model itself.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| ttlopt | BOOLEAN | false | Enable to set ttl. Off uses the model's default. |
| ttl_valueopt | INT | 60 | Time-to-live (TTL) in seconds for generated content. Only applies when `outputType` is `URL`. |
| outputFormatopt | COMBO | JPG | File format for the generated image. |
| outputQualityopt | INT | 9520–99 | Compression quality of the output. Higher values preserve quality but increase file size. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |