Nodes/ComfyUI_StarNodes/⭐ Star Lucida RMBG
ComfyUI Node

⭐ Star Lucida RMBG

Background removal that keeps glass, camouflage, text and line art intact

By Starnodes2024·Created 2 years ago·Updated 2 days ago· 106
⭐ Star Lucida RMBG
  • image
  • rgba_image
  • mask
refinefalse
decontaminatetrue
dtypefp32
deviceauto

Background removal is the most commoditized job in this ecosystem - BiRefNet is the KB-endorsed default and even ships inside ComfyUI now - but "remove the background" still fails on the same stubborn cases: glass, camouflage, text with soft shadows, glow, and line art. Star Lucida RMBG is the StarNodes answer to those cases. It wraps Lucida, a BiRefNet fine-tune by egeorcun that was trained specifically to survive semi-transparency and camouflaged subjects, and it's the one you reach for when the generic cutout eats your glass or ghosts your line art.

How it works

The model auto-downloads from HuggingFace on first use (model.safetensors from the egeorcun/lucida repo) into ComfyUI/models/lucida/ - no manual fetching, though the node prints a clear message if the download fails so you can place the file by hand. Batches are processed one image at a time. On the quality side you get two genuine upgrades over a bare BiRefNet node:

  • refine (default off) - an edge-refinement pass that re-runs the model on the uncertain alpha band at higher effective resolution. Slower, noticeably sharper edges on hair and fine detail. Turn it on for hero shots, leave it off for bulk work.
  • decontaminate (default on) - cleans background color spill out of the RGB channels of your cut-out. Uses pymatting's proper foreground estimation if you have it installed, and falls back to a built-in nearest-color cleaner if you don't (the node prints a hint to pip install pymatting for the exact upstream result).

Then the practical settings: dtype - fp32 matches the reference pipeline exactly; bf16/fp16 roughly halve VRAM on a GPU, and CPU always runs fp32 regardless. device defaults to auto (ComfyUI's device), with explicit cuda/cpu if you want control.

Inputs and outputs

  • image - input (batches handled one by one).
  • refine, decontaminate, dtype, device - the quality and resource knobs above.
  • rgba_image (out) - the 4-channel cut-out. Save it as PNG to keep the transparency; JPEG can't hold it.
  • mask (out) - the alpha matte as a MASK, for compositing or further processing.

Installing

Part of the StarNodes pack - install Starnodes via ComfyUI Manager, or:

cd ComfyUI/custom_nodes
git clone https://github.com/Starnodes2024/ComfyUI_StarNodes
cd ComfyUI_StarNodes
pip install -r requirements.txt

The model (roughly a BiRefNet-sized safetensors) downloads automatically on first run. For best decontamination, also pip install pymatting.

Common issues

If nothing happens on first run, check the console for the download message - a blocked network leaves you with a path to place the file manually. On a 6GB card, fp32 can OOM on big inputs; switch dtype to bf16/fp16 first, then consider refine off. And the recurring gotcha: save the cut-out as PNG, or your carefully kept transparency silently becomes black or white. If edges look hard when you wanted soft matting, remember this is a BiRefNet-family model - it predicts strong alpha, not a fractional matte; refine sharpens, it doesn't soften.

Category⭐StarNodes/Image And Latent

Inputs (5)

NameTypeDefaultDescription
imageIMAGEInput image (batches processed one by one)
refineBOOLEANfalseEdge-refinement pass: re-runs the model on the uncertain alpha band at higher effective resolution. Slower, sharper edges.
decontaminateBOOLEANtrueClean background colour spill from the RGB channels of the cut-out (uses pymatting if installed, otherwise a built-in nearest-colour fallback).
dtypeCOMBOfp32fp32 matches the reference pipeline. bf16/fp16 roughly halve VRAM on GPU. CPU always runs fp32.
deviceCOMBOauto'auto' uses ComfyUI's device.

Outputs (2)

NameTypeDescription
rgba_imageIMAGERGBA cut-out (4-channel IMAGE; save as PNG to keep transparency).
maskMASKAlpha matte as a MASK for compositing.