Files
rui40000-RUI-Nodes/lucida/__init__.py
T
rui40000andClaude Opus 4.8 d47fd27062 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>
2026-07-29 11:08:35 +08:00

19 lines
804 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# -*- coding: utf-8 -*-
"""
Lucida 模型代码(内嵌自 https://huggingface.co/egeorcun/lucida ,MIT)
=====================================================================
Lucida 是 BiRefNet_HR 的微调版,专攻伪装物体、透明材质、文字/Logo、
VFX 光效与插画。模型实现(birefnet.py / BiRefNet_config.py)与上游逐字节一致。
内嵌而非用 trust_remote_code 在线加载的原因:
- trust_remote_code=True 会从 HuggingFace 拉取并执行远程 Python 代码,
ComfyUI 场景下既不该联网,也不该在用户机器上执行随时可变的远程代码;
- 内嵌后版本固定、可离线、可审计。
"""
# ruff: noqa: F401
from .birefnet import BiRefNet
from .BiRefNet_config import BiRefNetConfig
__all__ = ["BiRefNet", "BiRefNetConfig"]