Lucida 抠图 / Lucida Matting
The matting model that keeps glass, text, and glow alive
- image
- alpha
- cutout
Most background removers quietly fail on the same five things: camouflaged objects, glass, text and logos, VFX glow, and illustration. Lucida 抠图 / Lucida Matting is a model that was trained to win those specific fights. It's a fine-tune of BiRefNet_HR (MIT-licensed, ~885MB, 220M params, Swin-Large backbone), and the author's own 203-image benchmark puts it ahead of a commercial reference on text/logo retention (0.0091 vs 0.0123 MAE) with strong numbers on illustration, camo, and sticker prints.
Like FeyNobg, it's fully automatic - no prompt, no box. First run pulls the weights to ComfyUI/models/lucida/lucida.safetensors automatically.
What it's good at, honestly
This is the node to reach for when "foreground vs background" isn't a clean binary - when keeping the semi-transparent material is the whole point. Glass, smoke, light effects, a logo sitting on a sticker, an illustration with soft edges. The README's side-by-side with FeyNobg makes the philosophy explicit: on a picture of a character with clouds and railings, FeyNobg strips to the character alone while Lucida keeps the translucent clouds as foreground and preserves the railings. Neither is "wrong" - they define foreground differently, and Lucida's definition happens to include transparency. On your own material, run both (the pack even ships a workflow that parallels them) and pick by which cutout matches your intent.
Inputs and outputs
- image - batch-friendly, processed per-frame to cap VRAM. RGBA in drops the alpha channel.
- model_name - weights under
models/lucida; auto-downloads if absent. - precision - default fp16: half the VRAM, and measured nearly identical to fp32. Drop to fp32 only if you get a black frame or artifacts.
- device -
auto/cpu(CPU is painfully slow).
Optional: alpha_threshold / alpha_softness (same level-adjust pair as FeyNobg, defaults 0.5/1.0 = no-op), keep_aspect_ratio, invert_mask.
Outputs: alpha (MASK) and cutout (IMAGE on black). Transparent PNG needs a JoinImageWithAlpha-style step downstream.
One thing this node deliberately doesn't have: a resolution selector. The model's decoder is hard-bound to 1024×1024 via patch-split, so unlike FeyNobg there's no 512/768/1280 ladder. You get the native size, and that's that.
The design choice worth knowing about
Most BiRefNet nodes load with trust_remote_code, which means at runtime they pull and execute Python from HuggingFace. This node instead embeds the model code (2,250 lines) inside the pack - pinned version, works offline, auditable - and skips the ImageNet backbone download by constructing with bb_pretrained=False. Weight loading is strictly validated too: any mismatch aborts rather than silently degrading. It's the same careful engineering philosophy as the pack's FeyNobg node, and it's the reason these two are more trustworthy than the average trust_remote_code wrapper.
Troubleshooting
Black or garbage output → switch precision to fp32 and re-run; the fp16 path is solid but a bad environment can trip it. And resist the urge to crush alpha_softness toward 0 on glass or glow material - Lucida's whole reason to exist is preserving real semi-transparency, and a hard threshold throws that away.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | 待抠图的图像,支持批量(逐张推理,避免显存峰值过高)。 RGBA 输入会自动丢弃 alpha 只取 RGB。 | |
| model_name | COMBO | 放在 models/lucida 下的权重(.safetensors)。 未找到时首次运行会自动从 HuggingFace 下载egeorcun/lucida(约 885MB)。 | |
| precision | COMBO | fp16 | fp16 显存减半、速度更快,实测与 fp32 输出基本一致。 遇到黑图或异常时改回 fp32。 |
| device | COMBO | auto | auto = 有显卡就用显卡。 cpu 会慢十倍以上,仅在显存实在不够时用。 |
| alpha_thresholdopt | FLOAT | 0.500–1 | 多大置信度才算前景。模型对拿不准的区域会输出 0.5 上下的 中间值,表现为「整片主体半透明发灰」,调低可拉回不透明。 只对已有一定响应的区域有效。 |
| alpha_softnessopt | FLOAT | 1.000–1 | 阈值两侧过渡带宽度,决定边缘软硬。 1.0 = 完全不处理,原样输出模型结果(默认) 0.2~0.4 = 压掉灰雾但保留发丝级过渡 0 = 硬二值化。Lucida 强项之一是玻璃等真实半透明, 调小会把这类效果一并压掉,务必按素材取舍。 |
| keep_aspect_ratioopt | BOOLEAN | false | 模型固定吃 1024×1024,默认把图直接拉伸成正方形 (与官方用法一致)。长图/宽图形变严重时可开启, 改为等比缩放 + 边缘延展补边,推理后裁掉补边。 属试验性选项,常规比例建议关闭。 |
| invert_maskopt | BOOLEAN | false | 反转 alpha:默认前景为白(1),开启后前景为黑。 |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| alpha | MASK | — |
| cutout | IMAGE | — |