diff --git a/README.md b/README.md index 5d23933..a7bb62c 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,25 @@ SDMatte is an interactive image matting method based on Stable Diffusion, develo This plugin integrates SDMatte into ComfyUI, providing a simple and easy-to-use node interface focused on trimap-guided matting functionality with built-in VRAM optimization strategies. +## 🖼️ Examples + +### Matting Results + + + + + + + + + + + + +
Original ImageTrimapMatting Result
Alpha mask output
+ +*Example workflow demonstrating SDMatte's high-precision matting capabilities with trimap guidance.* + ## ✨ Features - 🎯 **High-Precision Matting**: Based on powerful diffusion model priors, capable of handling complex edge details diff --git a/README_CN.md b/README_CN.md index e23fadb..716ea4e 100644 --- a/README_CN.md +++ b/README_CN.md @@ -1,6 +1,6 @@ # ComfyUI-SDMatte -[English](README_EN.md) | 简体中文 +[English](README_CN.md) | 简体中文 基于 [SDMatte](https://github.com/vivoCameraResearch/SDMatte) 的 ComfyUI 自定义节点插件,用于交互式图像抠图。 @@ -10,6 +10,25 @@ SDMatte 是一个基于稳定扩散(Stable Diffusion)的交互式图像抠 本插件将 SDMatte 集成到 ComfyUI 中,提供简洁易用的节点接口,专注于 trimap 引导的抠图功能,并内置了多种 VRAM 优化策略。 +## 🖼️ 示例 + +### 抠图效果 + + + + + + + + + + + + +
原始图像三值图抠图结果
Alpha 遮罩输出
+ +*示例工作流展示了 SDMatte 基于三值图引导的高精度抠图能力。* + ## ✨ 特性 - 🎯 **高精度抠图**:基于扩散模型的强大先验,能够处理复杂边缘细节 @@ -50,7 +69,7 @@ ComfyUI 会在启动时自动安装 `requirements.txt` 中的依赖包: wget https://huggingface.co/LongfeiHuang/SDMatte/resolve/main/SDMatte.pth ``` -**增强版本(SDMatte*):** +**增强版本(SDMatte+):** ```bash # 下载增强版本权重文件(更高精度,更大模型) wget https://huggingface.co/LongfeiHuang/SDMatte/resolve/main/SDMatte_plus.pth @@ -68,7 +87,6 @@ ComfyUI/models/checkpoints/ - **SDMatte.pth**:标准版本,平衡性能和质量,推荐日常使用 - **SDMatte_plus.pth**:增强版本,更高精度但需要更多显存和计算时间,适合高质量需求 - ### 4. 重启 ComfyUI 重启 ComfyUI 以加载新的自定义节点。 @@ -190,4 +208,4 @@ A: --- -**注意**:本插件为第三方实现,与原始 SDMatte 团队无直接关联。使用前请确保遵循相关许可证条款。 +**注意**:本插件为第三方实现,与原始 SDMatte 团队无直接关联。使用前请确保遵循相关许可证条款。 \ No newline at end of file diff --git a/example_workflow/example_workflow.json b/example_workflow/example_workflow.json new file mode 100644 index 0000000..a6bd5ee --- /dev/null +++ b/example_workflow/example_workflow.json @@ -0,0 +1,396 @@ +{ + "id": "500ae763-00a0-4a77-839d-fab74ac03ec3", + "revision": 0, + "last_node_id": 12, + "last_link_id": 17, + "nodes": [ + { + "id": 11, + "type": "SDMatteApply", + "pos": [ + 7681.2158203125, + -325.66558837890625 + ], + "size": [ + 270, + 146 + ], + "flags": {}, + "order": 4, + "mode": 0, + "inputs": [ + { + "name": "sdmatte_model", + "type": "SDMATTE_MODEL", + "link": 17 + }, + { + "name": "image", + "type": "IMAGE", + "link": 14 + }, + { + "name": "trimap", + "type": "MASK", + "link": 15 + } + ], + "outputs": [ + { + "name": "MASK", + "type": "MASK", + "links": [ + 16 + ] + } + ], + "properties": { + "enableTabs": false, + "tabWidth": 65, + "tabXOffset": 10, + "hasSecondTab": false, + "secondTabText": "Send Back", + "secondTabOffset": 80, + "secondTabWidth": 65, + "Node name for S&R": "SDMatteApply", + "ue_properties": { + "widget_ue_connectable": { + "inference_size": true, + "is_transparent": true, + "force_cpu": true + } + } + }, + "widgets_values": [ + 1024, + false, + false + ] + }, + { + "id": 5, + "type": "LayerMask: SegmentAnythingUltra V2", + "pos": [ + 7274.59326171875, + -50.851478576660156 + ], + "size": [ + 390.8785095214844, + 366 + ], + "flags": {}, + "order": 2, + "mode": 0, + "inputs": [ + { + "name": "image", + "type": "IMAGE", + "link": 4 + } + ], + "outputs": [ + { + "name": "image", + "type": "IMAGE", + "links": null + }, + { + "name": "mask", + "type": "MASK", + "links": [ + 8, + 15 + ] + } + ], + "properties": { + "enableTabs": false, + "tabWidth": 65, + "tabXOffset": 10, + "hasSecondTab": false, + "secondTabText": "Send Back", + "secondTabOffset": 80, + "secondTabWidth": 65, + "cnr_id": "ComfyUI_LayerStyle_Advance", + "ver": "5f8c6f29c484100245bc6f8ea66277f53e23cdbe", + "Node name for S&R": "LayerMask: SegmentAnythingUltra V2", + "ue_properties": { + "widget_ue_connectable": { + "sam_model": true, + "grounding_dino_model": true, + "threshold": true, + "detail_method": true, + "detail_erode": true, + "detail_dilate": true, + "black_point": true, + "white_point": true, + "process_detail": true, + "prompt": true, + "device": true, + "max_megapixels": true, + "cache_model": true + } + } + }, + "widgets_values": [ + "sam_vit_h (2.56GB)", + "GroundingDINO_SwinT_OGC (694MB)", + 0.3, + "VITMatte", + 6, + 6, + 0.15, + 0.99, + true, + "subject", + "cuda", + 2, + false + ], + "color": "rgba(27, 80, 119, 0.7)" + }, + { + "id": 7, + "type": "MaskPreview+", + "pos": [ + 8068.8037109375, + -313.58538818359375 + ], + "size": [ + 218.03030395507812, + 307.784912109375 + ], + "flags": {}, + "order": 5, + "mode": 0, + "inputs": [ + { + "name": "mask", + "type": "MASK", + "link": 16 + } + ], + "outputs": [], + "properties": { + "enableTabs": false, + "tabWidth": 65, + "tabXOffset": 10, + "hasSecondTab": false, + "secondTabText": "Send Back", + "secondTabOffset": 80, + "secondTabWidth": 65, + "cnr_id": "comfyui_essentials", + "ver": "9d9f4bedfc9f0321c19faf71855e228c93bd0dc9", + "Node name for S&R": "MaskPreview+", + "ue_properties": { + "widget_ue_connectable": {} + } + }, + "widgets_values": [] + }, + { + "id": 8, + "type": "MaskPreview+", + "pos": [ + 8352.73828125, + -312.1937561035156 + ], + "size": [ + 216.50474548339844, + 305.49658203125 + ], + "flags": {}, + "order": 3, + "mode": 0, + "inputs": [ + { + "name": "mask", + "type": "MASK", + "link": 8 + } + ], + "outputs": [], + "properties": { + "enableTabs": false, + "tabWidth": 65, + "tabXOffset": 10, + "hasSecondTab": false, + "secondTabText": "Send Back", + "secondTabOffset": 80, + "secondTabWidth": 65, + "cnr_id": "comfyui_essentials", + "ver": "9d9f4bedfc9f0321c19faf71855e228c93bd0dc9", + "Node name for S&R": "MaskPreview+", + "ue_properties": { + "widget_ue_connectable": {} + } + }, + "widgets_values": [] + }, + { + "id": 6, + "type": "LoadImage", + "pos": [ + 6951.2880859375, + -31.12131690979004 + ], + "size": [ + 270, + 314 + ], + "flags": {}, + "order": 0, + "mode": 0, + "inputs": [], + "outputs": [ + { + "name": "IMAGE", + "type": "IMAGE", + "links": [ + 4, + 14 + ] + }, + { + "name": "MASK", + "type": "MASK", + "links": null + } + ], + "properties": { + "enableTabs": false, + "tabWidth": 65, + "tabXOffset": 10, + "hasSecondTab": false, + "secondTabText": "Send Back", + "secondTabOffset": 80, + "secondTabWidth": 65, + "cnr_id": "comfy-core", + "ver": "0.3.49", + "Node name for S&R": "LoadImage", + "ue_properties": { + "widget_ue_connectable": { + "image": true, + "upload": true + } + } + }, + "widgets_values": [ + "pasted/image (92).png", + "image" + ] + }, + { + "id": 12, + "type": "SDMatteModelLoader", + "pos": [ + 7178.95458984375, + -334.05029296875 + ], + "size": [ + 371.62713623046875, + 58 + ], + "flags": {}, + "order": 1, + "mode": 0, + "inputs": [], + "outputs": [ + { + "name": "SDMATTE_MODEL", + "type": "SDMATTE_MODEL", + "links": [ + 17 + ] + } + ], + "properties": { + "enableTabs": false, + "tabWidth": 65, + "tabXOffset": 10, + "hasSecondTab": false, + "secondTabText": "Send Back", + "secondTabOffset": 80, + "secondTabWidth": 65, + "Node name for S&R": "SDMatteModelLoader", + "ue_properties": { + "widget_ue_connectable": { + "ckpt_name": true + } + } + }, + "widgets_values": [ + "other\\SDMatte_plus.pth" + ] + } + ], + "links": [ + [ + 4, + 6, + 0, + 5, + 0, + "IMAGE" + ], + [ + 8, + 5, + 1, + 8, + 0, + "MASK" + ], + [ + 14, + 6, + 0, + 11, + 1, + "IMAGE" + ], + [ + 15, + 5, + 1, + 11, + 2, + "MASK" + ], + [ + 16, + 11, + 0, + 7, + 0, + "MASK" + ], + [ + 17, + 12, + 0, + 11, + 0, + "SDMATTE_MODEL" + ] + ], + "groups": [], + "config": {}, + "extra": { + "ue_links": [], + "ds": { + "scale": 0.6727499949325685, + "offset": [ + -6553.623941286115, + 658.8196674498315 + ] + }, + "links_added_by_ue": [], + "frontendVersion": "1.23.4", + "VHS_latentpreview": false, + "VHS_latentpreviewrate": 0, + "VHS_MetadataImage": true, + "VHS_KeepIntermediate": true + }, + "version": 0.4 +} \ No newline at end of file diff --git a/example_workflow/test_1.png b/example_workflow/test_1.png new file mode 100644 index 0000000..500cdf2 Binary files /dev/null and b/example_workflow/test_1.png differ diff --git a/example_workflow/test_2.png b/example_workflow/test_2.png new file mode 100644 index 0000000..349ba78 Binary files /dev/null and b/example_workflow/test_2.png differ