v1.1.0: Optimize dependency management and improve documentation

This commit is contained in:
Cyber Dick Lang
2025-06-09 18:10:23 +08:00
parent a35c8b7673
commit 9da405414a
5 changed files with 98 additions and 92 deletions
+74 -79
View File
@@ -1,92 +1,87 @@
# ComfyUI-RemoveBackgroundSuite
![image](https://github.com/user-attachments/assets/75fb08b6-184d-46e1-a4e6-3294dd94d66d)
> 基于 ComfyUI 的抠图套件,支持多种抠图模型和细节处理方式。
A matting toolkit based on ComfyUI, supporting multiple matting models and detail processing methods.
## 版本信息
## Features
- 当前版本:v0.2
- 更新日期:2024-06-XX
- **Multiple Models**: Support for various matting models including BiRefNet, RMBG, and more
- **Detail Processing**: Advanced mask processing capabilities for fine-tuning results
- **User-Friendly**: Simple and intuitive interface within ComfyUI
- **High Performance**: Optimized for both quality and speed
## 更新日志
## Installation
### v0.2 (2024-06-XX)
- BiRefNetUltraV3_RBS 节点合并模型加载功能,直接选择模型版本,无需单独加载节点。
- BiRefNetUltraV3_RBS、TransparentBackgroundUltra_RBS 节点的 max_megapixels 参数支持动态调整分辨率,自动缩放为32的倍数,防止patch分割报错。
- 新增 Mask Process Details (RBS) 节点,支持VITMatte/GuidedFilter等多种细节处理方法,参数可调。
- 节点命名与界面优化,部分节点重命名。
- 细节处理参数范围优化。
### v1.2 (2024-06-XX)
- 节点界面极简化,移除所有细节处理相关参数和功能。
- TransparentBackgroundUltra_RBS 去除 WIP 标志。
### v1.1 (2024-03-21)
- 优化 BiRefNet 模型加载逻辑,支持 dynamic、HR、HR-matting 模型
- 优化 VITMatte 模型加载和推理流程
- 改进文档结构和说明
### v1.0 (2024-03-20)
- 初始版本发布
- 支持 BiRefNet 和 TransparentBackground 两种抠图模型
## 节点说明
### 1. BiRefNet Ultra V3 (RBS)
- **功能**:使用 BiRefNet Ultra V3 进行高质量背景移除,支持 dynamic/HR/HR-matting 等多种模型。
- **参数**:
- `image`:输入图片(支持批量)。
- `version`:选择模型版本(BiRefNet-General、RMBG-2.0、BiRefNet_dynamic等)。
- `device`、`max_megapixels`:详见节点界面。max_megapixels 会自动动态缩放分辨率为32的倍数。
- **输出**:
- `image`:去背景后的 RGBA 图片
- `mask`:前景掩码
### 2. Transparent Background Ultra (RBS)
- **功能**:将图片背景转换为透明。
- **参数**:
- `image`:输入图片。
- `model`:选择本地模型。
- `device`、`max_megapixels`:详见节点界面。max_megapixels 会自动动态缩放分辨率为32的倍数。
- **输出**:
- `image`:透明背景图片
- `mask`:前景掩码
### 3. Mask Process Details (RBS)
- **功能**:对输入图像和mask进行细节优化,支持VITMatte、GuidedFilter等多种方法。
- **参数**:
- `image`:输入图片。
- `mask`:输入掩码。
- `detail_method`:细节处理方法(VITMatte、VITMatte(local)、GuidedFilter)。
- `detail_erode`、`detail_dilate`、`black_point`、`white_point`、`device`、`max_megapixels`:详见节点界面。
- **输出**:
- `image`:优化后的图片
- `mask`:优化后的掩码
## 典型用法
1. 用 `BiRefNet Ultra V3 (RBS)` 进行背景移除。
2. 可选:用 `Mask Process Details (RBS)` 进一步优化边缘细节。
3. 可选:用 `Transparent Background Ultra (RBS)` 处理透明背景。
## 注意事项
- 请将模型文件放在 `ComfyUI/models/transparent-background/` 目录下,或使用新版节点自动下载。
- 推荐使用 CUDA 设备以获得更快推理速度。
- 细节处理方法对边缘质量有显著影响,可根据实际需求调整。
- 插件所有节点均归类于 `RemoveBackgroundSuite`,便于统一管理。
## 依赖安装
1. Navigate to your ComfyUI's `custom_nodes` directory
2. Clone this repository:
```bash
git clone https://github.com/whmc76/ComfyUI-RemoveBackgroundSuite.git
```
3. Install dependencies:
```bash
cd ComfyUI-RemoveBackgroundSuite
pip install -r requirements.txt
```
## 常见问题
- **模型下载失败**:请检查网络连接或手动下载模型放入指定目录。
- **推理慢/显存不足**:可适当降低 `max_megapixels` 或切换到 CPU。
- **节点不显示**:请确认插件已放入 `custom_nodes` 目录并重启 ComfyUI。
## Usage
---
1. Start ComfyUI
2. The new nodes will appear in the node menu under the "RBS" category
3. Connect the nodes as needed in your workflow
## 致谢
本插件大量借鉴和参考了 [ComfyUI_LayerStyle_Advance](https://github.com/chflame163/ComfyUI_LayerStyle_Advance) 项目的设计与实现,特别感谢原作者 chflame163 的开源贡献!
## Models
如有更多问题请参考原项目文档或在 Issues 区反馈。
The following models are supported:
- BiRefNet-General
- BiRefNet_dynamic
- BiRefNet_HR
- BiRefNet_HR-matting
- RMBG-2.0
## Nodes
### BiRefNetUltraV3_RBS
- **Input**: Image
- **Output**: Mask
- **Parameters**:
- Model Version: Select from available BiRefNet models
- Max Megapixels: Maximum image size for processing
### Transparent Background Ultra (RBS)
- **Input**: Image
- **Output**: Transparent Image
- **Parameters**:
- Model Version: Select from available models
- Max Megapixels: Maximum image size for processing
### Mask Process Details (RBS)
- **Input**: Mask
- **Output**: Processed Mask
- **Parameters**:
- Blur Radius: Gaussian blur radius for mask smoothing
- Feather Radius: Edge feathering radius
- Contrast: Mask contrast adjustment
- Brightness: Mask brightness adjustment
## Changelog
### v1.1.0
- Optimized dependency management
- Removed version constraints for better compatibility
- Removed unused dependencies
- Improved code organization
### v1.0.0
- Initial release with core functionality
- Support for multiple matting models
- Basic mask processing capabilities
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## Acknowledgments
- [ComfyUI](https://github.com/comfyanonymous/ComfyUI) for the amazing framework
- [BiRefNet](https://github.com/ZhengPeng7/BiRefNet) for the matting models
- [RMBG](https://github.com/briaai/RMBG-2.0) for the background removal model
+1 -1
View File
@@ -2,4 +2,4 @@ from .nodes import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS
__all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS']
__version__ = 'v0.2'
__version__ = 'v1.1.0'
+13 -1
View File
@@ -240,7 +240,7 @@ class ProcessDetails_RBS:
"required": {
"image": ("IMAGE",),
"mask": ("MASK",),
"detail_method": (["VITMatte", "VITMatte(local)", "GuidedFilter"], {"default": "VITMatte"}),
"detail_method": (["VITMatte", "VITMatte(local)", "PyMatting", "GuidedFilter"], {"default": "VITMatte"}),
"detail_erode": ("INT", {"default": 4, "min": 1, "max": 100, "step": 1}),
"detail_dilate": ("INT", {"default": 2, "min": 1, "max": 100, "step": 1}),
"black_point": ("FLOAT", {"default": 0.01, "min": 0.01, "max": 0.98, "step": 0.01}),
@@ -267,6 +267,18 @@ class ProcessDetails_RBS:
local_files_only = detail_method == "VITMatte(local)"
trimap = generate_VITMatte_trimap(orig_mask, detail_erode, detail_dilate)
processed_mask = generate_VITMatte(orig_image, trimap, local_files_only, device, max_megapixels)
elif detail_method == "PyMatting":
trimap = generate_VITMatte_trimap(orig_mask, detail_erode, detail_dilate)
try:
from pymatting import estimate_alpha_lkm
except ImportError:
raise RuntimeError("请先安装 pymatting 库: pip install pymatting scikit-image")
import numpy as np
image_np = np.array(orig_image.convert('RGB'))
trimap_np = np.array(trimap.convert('L')) / 255.0
# PyMatting只用LKM算法,参数风格与LayerStyle_Advance一致
alpha = estimate_alpha_lkm(image_np, trimap_np)
processed_mask = Image.fromarray((alpha * 255).astype(np.uint8))
else: # GuidedFilter
processed_mask = mask_edge_detail(i, m, detail_erode, black_point, white_point)
processed_mask = tensor2pil(processed_mask)
+2 -2
View File
@@ -1,9 +1,9 @@
[project]
name = "removebackgroundsuite"
description = "A matting toolkit based on ComfyUI, supporting multiple matting models and detail processing methods."
version = "1.0.0"
version = "1.1.0"
license = {file = "LICENSE"}
dependencies = ["torch>=2.0.0", "numpy>=1.24.0", "Pillow>=9.0.0", "torchvision>=0.15.0", "opencv-python>=4.8.0", "scipy>=1.10.0", "transformers>=4.30.0", "huggingface-hub>=0.16.0", "tqdm>=4.65.0"]
dependencies = ["torch", "numpy", "Pillow", "torchvision", "opencv-python", "scipy", "transformers", "tqdm"]
[project.urls]
Repository = "https://github.com/whmc76/ComfyUI-RemoveBackgroundSuite"
+8 -9
View File
@@ -1,9 +1,8 @@
torch>=2.0.0
numpy>=1.24.0
Pillow>=9.0.0
torchvision>=0.15.0
opencv-python>=4.8.0
scipy>=1.10.0
transformers>=4.30.0
huggingface-hub>=0.16.0
tqdm>=4.65.0
torch
numpy
Pillow
opencv-python
scipy
torchvision
transformers
tqdm