- 新增 O1keyRemoveBackground 节点(基于 rembg CPU 推理) - 新增 O1keyColorRemoveBG 节点(颜色距离去背景,支持多模式) - 新增 O1keySavePSD 节点(手写 PSD 二进制,零外部依赖) - GPT Image 批量输出不同尺寸时自动 resize 对齐 - 聊天面板大幅增强(多模态/交互优化) - 重启按钮绕过 beforeunload 弹窗强制刷新 - 默认路由切换为 CF加速 - http_error 新增 system error 友好文案 Co-Authored-By: Claude Opus 4.7 <[email protected]>
37 lines
897 B
Python
37 lines
897 B
Python
"""
|
|
o1key 去背景节点
|
|
基于 rembg 实现,支持 CPU 推理
|
|
"""
|
|
|
|
import numpy as np
|
|
import torch
|
|
|
|
|
|
class O1keyRemoveBackground:
|
|
"""
|
|
移除图像背景,输出 RGBA 透明图层
|
|
|
|
基于 rembg (ISNet-General-Use) 模型,支持 CPU 推理。
|
|
首次运行会自动下载模型(约 170MB)。
|
|
"""
|
|
|
|
@classmethod
|
|
def INPUT_TYPES(cls):
|
|
return {
|
|
"required": {
|
|
"image": ("IMAGE",),
|
|
},
|
|
}
|
|
|
|
RETURN_TYPES = ("IMAGE",)
|
|
RETURN_NAMES = ("RGBA图像",)
|
|
FUNCTION = "remove_bg"
|
|
CATEGORY = "o1key/image"
|
|
|
|
def remove_bg(self, image):
|
|
from ..utils.rembg_utils import remove_background_tensor
|
|
print("[o1key 去背景] 正在处理...")
|
|
result = remove_background_tensor(image)
|
|
print(f"[o1key 去背景] 完成,输出 {result.shape[0]} 张 RGBA")
|
|
return (result,)
|