Remove an image background
Isolate your subject on a transparent background for layouts and compositing.
İş Akışını İndirCloud'da deneyin API belgeleri
İş akışının içinde
Kaynak şablonun salt okunur önizlemesi. Düğümleri incelemek ve değişiklik yapmak için Cloud'da açın.
Loading the graph
Open full-size workflow previewBu iş akışındaki dosyalar
- Yazar
- ComfyUI
Bu modeli kodunuzdan çağırın
Aşağıdaki istek, Playground ile aynı hazırlanmış grafiği ve ayarları kullanır. Her gönderim ücretli bir çalıştırma başlatabilir; sonucu bilinmeyen bir gönderimi otomatik olarak yeniden denemeyin.
1 API anahtarı al ↗
What you need
- Runs on
- Comfy Cloud
- Anahtar
- COMFY_API_KEY
- Dosyalarınız
- Kod tarafından URL'lerinden yüklenir
Ücretli bir Cloud planı ve kredi gerektirir.
# 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({
"17": {
"class_type": "LoadImage",
"inputs": {
"image": "UPLOADED_image_FILENAME"
},
"_meta": {
"title": "Load Image"
}
},
"18": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "Background_Removed",
"images": [
"19:16",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"19:13": {
"class_type": "RemoveBackground",
"inputs": {
"bg_removal_model": [
"19:14",
0
],
"image": [
"17",
0
]
},
"_meta": {
"title": "Remove Background"
}
},
"19:14": {
"class_type": "LoadBackgroundRemovalModel",
"inputs": {
"bg_removal_name": "birefnet.safetensors"
},
"_meta": {
"title": "Load Background Removal Model"
}
},
"19:15": {
"class_type": "InvertMask",
"inputs": {
"mask": [
"19:13",
0
]
},
"_meta": {
"title": "Invert Mask"
}
},
"19:16": {
"class_type": "JoinImageWithAlpha",
"inputs": {
"alpha": [
"19:15",
0
],
"image": [
"17",
0
]
},
"_meta": {
"title": "Join Image with Alpha"
}
}
})
workflow.set_input("17", "image", client.assets.from_url("https://cdn.jsdelivr.net/gh/Comfy-Org/workflow_templates@90c71fb78b3726392d010ff62a8e79e92d7296ad/input/the_lily_veil.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("18"):
output.to_file(output.name)