561 字
3 分钟
StableDiffusion:抠图
1.说明
在实际的图像处理过程中,经常需要使用抠图技术,以提取准确的前景目标。
2. Florence 2
使用Florence 2插件的caption_to_phrase_grounding功能,可对图像中的指定目标进行抠图。不过,当前景目标太大时,抠图会不准确或者不完整。
2.1 节点安装
- 节点网站:https://github.com/kijai/ComfyUI-Florence2
- 建议通过git clone安装
- 安装环境依赖:pip install -r requirements.txt
2.2 模型下载
- 下载位置:ComfyUI/models/LLM
| hf-mirror仓库 | modelscope仓库 |
|---|---|
| Florence-2-large | Florence-2-large |
| Florence-2-large-ft | Florence-2-large-ft |
| Florence-2-base | Florence-2-base |
| Florence-2-base-ft | Florence-2-base-ft |
2.3 节点使用

2.4 示例参考
| 参考图 | 准确抠图:cloth | 不准确抠图:person |
|---|---|---|
![]() | ![]() | ![]() |
![]() | ![]() | ![]() |
3. Florence 2 + SAM 2
SAM2全称是:Segment Anything Model 2,擅长在图像领域和视频领域中完成目标分割任务。它与Florence 2的目标检测功能相结合,会获得较好的目标分割效果。
3.1 节点安装
- 节点网站:https://github.com/kijai/ComfyUI-segment-anything-2
- 建议通过git clone安装
- 安装环境依赖:pip install -r requirements.txt
3.2 模型下载
3.3 节点使用

3.4 示例参考
| 参考图 | Florence 2目标检测 | 效果图:蒙版 | 效果图 |
|---|---|---|---|
![]() | ![]() | ![]() | ![]() |
4. Image Remove Bg
ComfyUI-Easy-Use组件里的Image Remove Bg节点可以用于提取输入图像中的前景目标,支持RMBG模型和Inspyrenet模型。
4.1 节点安装
- 节点网站:https://github.com/yolain/ComfyUI-Easy-Use
- 建议通过git clone安装
- 安装环境依赖:pip install -r requirements.txt
4.2 模型下载
4.3 节点使用

4.4 示例参考
| 参考图 | 效果图:RMBG-1.4 | 效果图:RMBG-2.0 | 效果图:Inspyrenet |
|---|---|---|---|
![]() | ![]() | ![]() | ![]() |
![]() | ![]() | ![]() | ![]() |
5. 总结
| 方式 | 输入:图像 | 能否指定目标 | 输出:蒙版 | 输出:裁剪图 | 效果 |
|---|---|---|---|---|---|
| Florence 2 | 🟢 | 🟢 | 🟢 | ❌ | 可以指定目标,抠图精度差 |
| Florence 2 + SAM 2 | 🟢 | 🟢 | 🟢 | ❌ | 可以指定目标,抠图效果好 |
| Image Remove Bg:RMBG-1.4 | 🟢 | ❌ | 🟢 | 🟢 | 效果很好,强制去除背景 |
| Image Remove Bg:RMBG-2.0 | 🟢 | ❌ | 🟢 | 🟢 | 效果很好,强制去除背景 |
| Image Remove Bg:InsPyrence | 🟢 | ❌ | 🟢 | 🟢 | 细节非常好,强制去除背景 |











