Remove an object
Remove an unwanted object using a black-and-white mask over the area to erase.
下载工作流在 Cloud 中试用 API 文档
查看工作流内部
源模板的只读预览。在 Cloud 中打开,即可查看节点并进行修改。
Loading the graph
Open full-size workflow preview- 作者
- ComfyUI
从代码中调用该模型
以下请求使用与体验区相同的预设图和设置。每次提交都可能开始一次付费运行;如果提交结果未知,请勿自动重试。
1 获取 API 密钥 ↗
What you need
- Runs on
- Comfy Cloud
- 密钥
- COMFY_API_KEY
- 你的文件
- 由代码根据链接上传
需要付费的 Cloud 方案和额度。
# Python 3.10+: pip install comfy-sdk==0.4.0
import os
from comfy_sdk import Comfy
api_key = os.environ.get("COMFY_API_KEY", "").strip()
if not api_key: raise RuntimeError("Set COMFY_API_KEY")
os.environ.setdefault("COMFY_BASE_URL", "https://cloud.comfy.org")
client = Comfy(api_key=api_key)
workflow = client.workflows.from_json({
"2": {
"class_type": "LoadImage",
"inputs": {
"image": "UPLOADED_image_FILENAME"
},
"_meta": {
"title": "Load Image"
}
},
"4": {
"class_type": "SaveImageAdvanced",
"inputs": {
"filename_prefix": "Bria_Eraser",
"format": "png",
"format.bit_depth": "8-bit",
"format.input_color_space": "sRGB",
"images": [
"15",
0
]
},
"_meta": {
"title": "Save Image (Advanced)"
}
},
"15": {
"class_type": "BriaEraser",
"inputs": {
"image": [
"2",
0
],
"mask": [
"workshop-mask",
0
],
"mask_type": "manual",
"moderation": "false"
},
"_meta": {
"title": "Bria Eraser"
}
},
"workshop-mask": {
"class_type": "LoadImageMask",
"inputs": {
"channel": "red",
"image": "UPLOADED_mask_FILENAME"
},
"_meta": {
"title": "Edit mask (white = edit)"
}
}
})
workflow.set_input("2", "image", client.assets.from_url("https://cdn.jsdelivr.net/gh/Comfy-Org/workflow_templates@90c71fb78b3726392d010ff62a8e79e92d7296ad/input/vintage_girl_yellow_apple.png"))
workflow.set_input("workshop-mask", "image", client.assets.from_url("https://comfy.org/workflow-inputs/remove-object-apple-mask.png"))
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)
for output in job.get_outputs("4"):
output.to_file(output.name)