Ghostwritten Remove Background
Drop an Image In, Get a Transparent PNG Out — One Node
- image
- birefnet_model
- rgba_image
- mask
This is the node that does the thing. Feed Ghostwritten Remove Background an
IMAGE, and you get back a transparent RGBA image plus the raw mask. Background
removal is the most commoditized operation in ComfyUI, and BiRefNet is the
default tool for it - the model that finally beat rembg's u2net on hair, fur,
and fine edges. What makes this particular node worth knowing is the package
deal: it works completely on its own, with no loader and no third-party
extension, and it bakes the mask cleanup right in. Blur, offset, invert - all
built in, instead of making you chain a MaskBlur and a Composite behind it.
How it works
The node resolves its model (from the optional loader handle if one is
connected, otherwise it lazy-loads by model_name), picks CUDA/MPS/CPU, and
runs the network the way the BiRefNet repo intends: the image is resized to the
model's input size, ImageNet-normalized, passed through the segmentation model,
and the output sigmoided into a 0–1 mask. The mask is then resized back to your
original resolution before the node touches it - so your cutout comes out at the
same size it went in. The last step packs the original RGB pixels with that mask
as the alpha channel.
That's why the outputs are what they are:
- rgba_image (
IMAGE) - a 4-channel image. Wire it straight into aSave Imagenode and ComfyUI writes the alpha channel, so you get a transparent PNG on disk. - mask (
MASK) - the raw foreground matte, 0–1. Feed it into compositing, inpainting region selection, or anything else that wants a mask instead of an image.
The inputs that actually matter
- model_name -
BiRefNet (general)is the default and right for most subjects.BiRefNet_lite (faster)trades accuracy for speed,BiRefNet-portraitis tuned for people, andBiRefNet HR (1536)is the pick for large inputs, at a VRAM cost. - mask_blur - feathers the matte edge in pixels. This is the one I'd actually reach for: a blur of 1–3 kills the hard, slightly crunchy edge you often get straight out of the network.
- mask_offset - grows (positive) or shrinks (negative) the matte. Handy when the cut is too tight around hair or the background is bleeding in.
- invert_mask - keeps the background instead of the subject. Exactly one thing, exactly when you want the other side.
precision defaults to fp16, which is right - but note it only applies on CUDA; the node silently runs fp32 on Mac and CPU either way.
Install
Same install for the whole pack, which also gives you the optional Ghostwritten BiRefNet Loader if you ever want one. ComfyUI Manager: search "comfyui-ghostwritten-BiRefNet" (or "Ghostwritten"). Or:
cd ComfyUI/custom_nodes
git clone https://github.com/GhostwrittenStudios/comfyui-ghostwritten-BiRefNet
Then restart ComfyUI. It needs timm, einops, and kornia on top of what
ComfyUI already ships; the first run downloads the model weights from Hugging
Face (a few hundred MB for the general weights, cached afterwards in
~/.cache/huggingface), so a long first run is a download, not a hang.
Where people get burned
The resolution cap is the one to know: the node resizes internally to 1024px (1536 for the HR variant), regardless of your source. A 4K render still gets downscaled, so above roughly 1500px reach for the HR model - or just use the BiRefNet that ComfyUI has shipped natively since May 2026, which this pack doesn't read from (it pulls its own weights via Hugging Face).
Also be honest about what a segmentation model can't do. If your subject is a veil, a wine glass, or smoke, this pack has no matting weights to fix it - it exposes only the general, lite, portrait, and HR variants, and a binary mask structurally cannot represent a half-transparent pixel. And if your plan was to use this to strip backgrounds from a LoRA training set: don't. It teaches the model to draw blank backgrounds.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| birefnet_modelopt | BIREFNET_MODEL | — | |
| model_nameopt | COMBO | 4 options: BiRefNet (general), BiRefNet_lite (faster), BiRefNet-portrait, BiRefNet HR (1536) | |
| precisionopt | COMBO | fp16 | 2 options: fp16, fp32 |
| mask_bluropt | INT | 00–64 | — |
| mask_offsetopt | INT | 0-32–32 | — |
| invert_maskopt | BOOLEAN | false | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| rgba_image | IMAGE | — |
| mask | MASK | — |