feat: 新增 Lucida 抠图节点(BiRefNet_HR 微调,擅长文字/Logo/插画/玻璃)

模型 https://huggingface.co/egeorcun/lucida (MIT),220M 参数、885MB。
作者基准:文字/Logo 0.0091(商业参考 0.0123)、插画 0.0092、
伪装 0.0270、总体 0.0257。

- 模型代码(2250 行)内嵌 lucida/ 子包,不用 trust_remote_code:
  那会在运行时拉取并执行远程代码,ComfyUI 场景既不该联网也不该如此;
  构造传 bb_pretrained=False,避免联网拉 Swin 预训练权重
- 预处理规格与 BiRefNet 系一致,复用 FeyNobg 那份已验证实现;
  输出适配 list 格式(eval 下 forward 返回各尺度预测,取 [-1])
- 权重加载严格校验,除窗口尺寸推出的确定性 buffer 外失配即中止
- 不开放分辨率选项:模型 Config.size=1024 且 decoder 走 patch split

示例工作流把 Lucida 与 FeyNobg 并联便于同图对照。实测两者差异
不是精度高低而是「前景」定义不同:同一张动漫插画上 FeyNobg 只抠人物
(前景占比 0.098),Lucida 还把半透明的云判为前景(0.391),
与其训练透明材质的目标一致,两者互补。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
rui40000
2026-07-29 11:08:35 +08:00
co-authored by Claude Opus 4.8
parent be93fd36a3
commit d47fd27062
7 changed files with 2967 additions and 0 deletions
+338
View File
@@ -0,0 +1,338 @@
{
"id": "7c2f9b18-4e63-4d05-a9f7-2b8e6c1d5a49",
"revision": 0,
"last_node_id": 11,
"last_link_id": 10,
"nodes": [
{
"id": 1,
"type": "LoadImage",
"pos": [-1700, 400],
"size": [300, 330],
"flags": {},
"order": 0,
"mode": 0,
"inputs": [],
"outputs": [
{
"label": "图像",
"name": "IMAGE",
"type": "IMAGE",
"links": [1, 2, 3]
},
{
"label": "遮罩",
"name": "MASK",
"type": "MASK",
"links": []
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.49",
"Node name for S&R": "LoadImage"
},
"widgets_values": ["example.png", "image"],
"title": "① 加载原图"
},
{
"id": 2,
"type": "RuiLucida",
"pos": [-1340, 400],
"size": [340, 240],
"flags": {},
"order": 1,
"mode": 0,
"inputs": [
{
"name": "image",
"type": "IMAGE",
"link": 1
}
],
"outputs": [
{
"name": "alpha",
"type": "MASK",
"links": [4, 5]
},
{
"name": "cutout",
"type": "IMAGE",
"links": [6]
}
],
"properties": {
"aux_id": "rui40000/Ruinode",
"Node name for S&R": "RuiLucida"
},
"widgets_values": ["lucida.safetensors", "fp16", "auto", 0.5, 1, false, false],
"color": "#232",
"bgcolor": "#353",
"title": "② Lucida 抠图(擅长文字/Logo、插画、玻璃)"
},
{
"id": 3,
"type": "RuiFeyNobg",
"pos": [-1340, 880],
"size": [340, 260],
"flags": {},
"order": 2,
"mode": 0,
"inputs": [
{
"name": "image",
"type": "IMAGE",
"link": 2
}
],
"outputs": [
{
"name": "alpha",
"type": "MASK",
"links": [7]
},
{
"name": "cutout",
"type": "IMAGE",
"links": []
}
],
"properties": {
"aux_id": "rui40000/Ruinode",
"Node name for S&R": "RuiFeyNobg"
},
"widgets_values": ["FeyNobg", 1024, "fp16", "auto", 0.5, 1, false, false],
"title": "③ 对照组:FeyNobg(不需要时可 Ctrl+M 静音)"
},
{
"id": 4,
"type": "MaskPreview",
"pos": [-960, 400],
"size": [300, 320],
"flags": {},
"order": 3,
"mode": 0,
"inputs": [
{
"label": "遮罩",
"name": "mask",
"type": "MASK",
"link": 4
}
],
"outputs": [],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.49",
"Node name for S&R": "MaskPreview"
},
"widgets_values": [],
"color": "#232",
"bgcolor": "#353",
"title": "Lucida alpha"
},
{
"id": 5,
"type": "PreviewImage",
"pos": [-620, 400],
"size": [320, 320],
"flags": {},
"order": 4,
"mode": 0,
"inputs": [
{
"name": "images",
"type": "IMAGE",
"link": 6
}
],
"outputs": [],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.49",
"Node name for S&R": "PreviewImage"
},
"widgets_values": [],
"title": "Lucida cutout(黑底)"
},
{
"id": 6,
"type": "InvertMask",
"pos": [-960, 760],
"size": [200, 26],
"flags": {},
"order": 5,
"mode": 0,
"inputs": [
{
"name": "mask",
"type": "MASK",
"link": 5
}
],
"outputs": [
{
"name": "MASK",
"type": "MASK",
"links": [8]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.49",
"Node name for S&R": "InvertMask"
},
"widgets_values": [],
"title": "反相(JoinImageWithAlpha 内部会再反一次)"
},
{
"id": 7,
"type": "JoinImageWithAlpha",
"pos": [-960, 830],
"size": [220, 46],
"flags": {},
"order": 6,
"mode": 0,
"inputs": [
{
"name": "image",
"type": "IMAGE",
"link": 3
},
{
"name": "alpha",
"type": "MASK",
"link": 8
}
],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [9, 10]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.49",
"Node name for S&R": "JoinImageWithAlpha"
},
"widgets_values": [],
"title": "合成透明背景 RGBA"
},
{
"id": 8,
"type": "PreviewImage",
"pos": [-620, 760],
"size": [320, 320],
"flags": {},
"order": 7,
"mode": 0,
"inputs": [
{
"name": "images",
"type": "IMAGE",
"link": 9
}
],
"outputs": [],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.49",
"Node name for S&R": "PreviewImage"
},
"widgets_values": [],
"color": "#232",
"bgcolor": "#353",
"title": "透明背景成品(RGBA)"
},
{
"id": 9,
"type": "SaveImage",
"pos": [-260, 760],
"size": [320, 320],
"flags": {},
"order": 8,
"mode": 0,
"inputs": [
{
"name": "images",
"type": "IMAGE",
"link": 10
}
],
"outputs": [],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.49",
"Node name for S&R": "SaveImage"
},
"widgets_values": ["lucida/cutout"],
"title": "保存透明 PNG"
},
{
"id": 10,
"type": "MaskPreview",
"pos": [-960, 1180],
"size": [300, 320],
"flags": {},
"order": 9,
"mode": 0,
"inputs": [
{
"label": "遮罩",
"name": "mask",
"type": "MASK",
"link": 7
}
],
"outputs": [],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.49",
"Node name for S&R": "MaskPreview"
},
"widgets_values": [],
"title": "FeyNobg alpha(对照)"
},
{
"id": 11,
"type": "Note",
"pos": [-1700, 800],
"size": [680, 520],
"flags": {},
"order": 10,
"mode": 0,
"inputs": [],
"outputs": [],
"properties": {},
"widgets_values": [
"Lucida 抠图 —— 使用要点\n\n【模型】首次运行自动下载到 ComfyUI/models/lucida/lucida.safetensors(约 885MB)。\n 也可手动下载 https://huggingface.co/egeorcun/lucida 的 model.safetensors,\n 改名为 lucida.safetensors 放进该目录。\n\n【它强在哪】Lucida 是 BiRefNet_HR 的微调版(MIT),作者在 203 图 9 类别\n 基准上的 MAE(越低越好):\n · 文字 / Logo 保留 0.0091(商业参考 0.0123)\n · 插画 0.0092\n · 伪装物体 0.0270\n · 印刷设计/贴纸 0.0235\n · 总体 0.0257\n 所以画面里有 Logo、艺术字、玻璃、发光特效、卡通插画时,优先用它。\n\n【三个抠图节点怎么选】\n · Lucida :文字/Logo、插画、玻璃、伪装物体 —— 这类素材首选\n · FeyNobg:常规主体照片,速度快\n · SDMatte:需要框/掩码提示,适合画面里多个主体、只抠其中一个\n 本工作流已并联 Lucida 与 FeyNobg,同一张图直接对照两者的 alpha。\n 只想跑 Lucida 时,选中 ③ 按 Ctrl+M 静音即可。\n\n【分辨率固定 1024】\n 模型内部 Config.size=1024 且 decoder 走 patch split,与 1024 输入绑定,\n 因此节点没有开放分辨率选项 —— 这点和 FeyNobg 不同。\n\n【主体半透明发灰】用 alpha_threshold / alpha_softness 拉色阶:\n · 默认 (0.5, 1.0) = 原样输出,一个像素都不动\n · (0.35, 0.3) = 压掉灰雾、保留边缘过渡\n ⚠ Lucida 的强项之一正是玻璃、发光这类**真实**半透明,\n softness 调小会把这些效果一并压实,按素材取舍,别无脑套用。\n\n【长图形变】模型固定吃 1024 方图,默认直接拉伸。手机截图这类 1:2 以上的\n 长图可开 keep_aspect_ratio 改为等比缩放 + 补边。属试验性选项。\n\n【透明 PNG】cutout 是黑底 RGB。要透明背景走这条链路:\n alpha → InvertMask → JoinImageWithAlpha(该节点内部会再反一次,故须先反相)"
],
"color": "#432",
"bgcolor": "#653"
}
],
"links": [
[1, 1, 0, 2, 0, "IMAGE"],
[2, 1, 0, 3, 0, "IMAGE"],
[3, 1, 0, 7, 0, "IMAGE"],
[4, 2, 0, 4, 0, "MASK"],
[5, 2, 0, 6, 0, "MASK"],
[6, 2, 1, 5, 0, "IMAGE"],
[7, 3, 0, 10, 0, "MASK"],
[8, 6, 0, 7, 1, "MASK"],
[9, 7, 0, 8, 0, "IMAGE"],
[10, 7, 0, 9, 0, "IMAGE"]
],
"groups": [],
"config": {},
"extra": {
"ds": {
"scale": 0.75,
"offset": [1900, -300]
}
},
"version": 0.4
}