Separate an image into editable layers
Decompose an image into transparent layers for further editing and compositing.
ワークフローをダウンロードCloudで試す API ドキュメント
ワークフローの内部
ソーステンプレートの読み取り専用プレビューです。Cloud で開くと、ノードを確認して変更できます。
Loading the graph
Open full-size workflow preview- 作成者
- ComfyUI
コードからこのモデルを呼び出す
以下のリクエストでは、Playground と同じ準備済みグラフと設定を使用します。送信ごとに有料実行が開始される場合があります。結果が不明な送信を自動的に再試行しないでください。
1 API キーを取得 ↗
What you need
- Runs on
- Comfy Cloud
- キー
- COMFY_API_KEY
- ファイル
- コードによって URL からアップロードされます
有料の 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({
"60": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "Qwen-image-layers",
"images": [
"83:8",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"74": {
"class_type": "LoadImage",
"inputs": {
"image": "UPLOADED_image_FILENAME"
},
"_meta": {
"title": "Load Image"
}
},
"82": {
"class_type": "ImageScaleToMaxDimension",
"inputs": {
"image": [
"74",
0
],
"largest_size": 640,
"upscale_method": "lanczos"
},
"_meta": {
"title": "Scale Image to Max Dimension"
}
},
"116": {
"class_type": "PrimitiveStringMultiline",
"inputs": {
"value": "A cinematic medium shot of a beautiful young woman with fair skin and a joyful, radiant smile, looking back over her shoulder. She has voluminous, curly auburn hair styled in a loose, windblown updo. She is standing on a rugged, rocky coastline overlooking a sun-drenched ocean. She wears a vintage, long-sleeved, high-collared dress in an off-white, crinkled fabric with delicate smocking on the bodice and a simple brown sash at her waist. In the background, the ocean sparkles brightly under the sun, and a majestic tall ship with full sails is visible in the distance. The scene is illuminated by the warm, golden light of the late afternoon, creating a soft, romantic, and nostalgic atmosphere with a shallow depth of field that keeps the woman in sharp focus."
},
"_meta": {
"title": "Prompt"
}
},
"83:118": {
"class_type": "EmptyQwenImageLayeredLatentImage",
"inputs": {
"batch_size": 1,
"height": [
"83:78",
1
],
"layers": 2,
"width": [
"83:78",
0
]
},
"_meta": {
"title": "Empty Qwen Image Layered Latent"
}
},
"83:140": {
"class_type": "LatentCut",
"inputs": {
"amount": 16384,
"dim": "t",
"index": 1,
"samples": [
"83:3",
0
]
},
"_meta": {
"title": "LatentCut"
}
},
"83:3": {
"class_type": "KSampler",
"inputs": {
"cfg": 2.5,
"denoise": 1,
"latent_image": [
"83:118",
0
],
"model": [
"83:66",
0
],
"negative": [
"83:70",
0
],
"positive": [
"83:69",
0
],
"sampler_name": "euler",
"scheduler": "simple",
"seed": 331728509923362,
"steps": 20
},
"_meta": {
"title": "KSampler"
}
},
"83:37": {
"class_type": "UNETLoader",
"inputs": {
"unet_name": "qwen_image_layered_bf16.safetensors",
"weight_dtype": "default"
},
"_meta": {
"title": "Load Diffusion Model"
}
},
"83:38": {
"class_type": "CLIPLoader",
"inputs": {
"clip_name": "qwen_2.5_vl_7b_fp8_scaled.safetensors",
"device": "default",
"type": "qwen_image"
},
"_meta": {
"title": "Load CLIP"
}
},
"83:39": {
"class_type": "VAELoader",
"inputs": {
"vae_name": "qwen_image_layered_vae.safetensors"
},
"_meta": {
"title": "Load VAE"
}
},
"83:6": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"83:38",
0
],
"text": [
"116",
0
]
},
"_meta": {
"title": "CLIP Text Encode (Positive Prompt)"
}
},
"83:66": {
"class_type": "ModelSamplingAuraFlow",
"inputs": {
"model": [
"83:37",
0
],
"sampling": "flow",
"shift": 1
},
"_meta": {
"title": "ModelSamplingAuraFlow"
}
},
"83:69": {
"class_type": "ReferenceLatent",
"inputs": {
"conditioning": [
"83:6",
0
],
"latent": [
"83:71",
0
]
},
"_meta": {
"title": "Set Reference Latent"
}
},
"83:7": {
"class_type": "CLIPTextEncode",
"inputs": {
"clip": [
"83:38",
0
],
"text": ""
},
"_meta": {
"title": "CLIP Text Encode (Negative Prompt)"
}
},
"83:70": {
"class_type": "ReferenceLatent",
"inputs": {
"conditioning": [
"83:7",
0
],
"latent": [
"83:71",
0
]
},
"_meta": {
"title": "Set Reference Latent"
}
},
"83:71": {
"class_type": "VAEEncode",
"inputs": {
"pixels": [
"82",
0
],
"vae": [
"83:39",
0
]
},
"_meta": {
"title": "VAE Encode"
}
},
"83:76": {
"class_type": "LatentCutToBatch",
"inputs": {
"dim": "t",
"samples": [
"83:140",
0
],
"slice_size": 1
},
"_meta": {
"title": "LatentCutToBatch"
}
},
"83:78": {
"class_type": "GetImageSize",
"inputs": {
"image": [
"82",
0
]
},
"_meta": {
"title": "Get Image Size"
}
},
"83:8": {
"class_type": "VAEDecode",
"inputs": {
"samples": [
"83:76",
0
],
"vae": [
"83:39",
0
]
},
"_meta": {
"title": "VAE Decode"
}
}
})
workflow.set_input("74", "image", client.assets.from_url("https://cdn.jsdelivr.net/gh/Comfy-Org/workflow_templates@90c71fb78b3726392d010ff62a8e79e92d7296ad/input/coastal_smiling_woman.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("60"):
output.to_file(output.name)