Qwen-Image-Layered Control Decomposition
Describe the elements you want in the image and decompose it precisely from the image.
简介
The Qwen-Image-Layered Control Decomposition workflow is designed to help users decompose an image into its constituent elements using the Qwen-Image-Layered model. This workflow is particularly useful for artists and designers who need to isolate specific parts of an image for further manipulation or analysis.
The process begins with loading an image using the LoadImage node, followed by scaling it to the desired dimensions with the ImageScaleToMaxDimension node. The core of the workflow involves the f754a936-daaf-4b6e-9658-41fdc54d301d node, which utilizes the Qwen-Image-Layered model to perform the decomposition.
This workflow is technically robust, allowing for precise control over image layers, which can be saved using the SaveImage node. The MarkdownNote node is used to document the process and provide guidance throughout the workflow. This layered decomposition is beneficial in scenarios where detailed image editing is required, such as in graphic design, digital art, and even in scientific imaging where specific features need to be isolated and analyzed.
你需要提供
- 正在读取工作流
在 ComfyUI 中运行。 此工作流无法在本页面运行。你可以在 Comfy Cloud 中打开(已预先加载所需内容),或下载后在自己的 ComfyUI 中使用。
在 Cloud 中试用查看工作流内部
节点图的只读预览。在 Comfy Cloud 中打开或下载后即可编辑节点。
Loading the graph
Open full-size workflow preview- 作者
- ComfyUI
需要自定义节点
- 正在读取工作流
通过代码使用此工作流
尽可能根据工作流图和输入自动生成代码,否则显示已保存的示例。运行代码可能产生费用,请先核对凭据和端点。
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({
"60": {
"class_type": "SaveImage",
"inputs": {
"filename_prefix": "Qwen-image-layers",
"images": [
"83:8",
0
]
},
"_meta": {
"title": "Save Image"
}
},
"74": {
"class_type": "LoadImage",
"inputs": {
"image": "raccoon_rocker.png"
},
"_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"
}
},
"83:3": {
"class_type": "KSampler",
"inputs": {
"cfg": 2.5,
"denoise": 1,
"latent_image": [
"83:83",
0
],
"model": [
"83:66",
0
],
"negative": [
"83:70",
0
],
"positive": [
"83:69",
0
],
"sampler_name": "euler",
"scheduler": "simple",
"seed": 657641993490688,
"steps": 20
},
"_meta": {
"title": "KSampler"
}
},
"83:37": {
"class_type": "UNETLoader",
"inputs": {
"unet_name": "qwen_image_layered_control_bf16.safetensors",
"weight_dtype": "fp8_e4m3fn"
},
"_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": "guitar"
},
"_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:3",
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"
}
},
"83:83": {
"class_type": "EmptyQwenImageLayeredLatentImage",
"inputs": {
"batch_size": 1,
"height": [
"83:78",
1
],
"layers": 2,
"width": [
"83:78",
0
]
},
"_meta": {
"title": "Empty Qwen Image Layered Latent"
}
}
})
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)常见问答
The recommended input size is 640px for standard use, and 1024px for high-resolution needs.
The model is computationally intensive, with original sampling settings of 50 steps and a CFG of 4.0, which can double the generation time.
This workflow is optimized for still images. For video, consider using a tool specifically designed for video processing.
You can learn more about subgraphs by visiting the Subgraph docs provided in the workflow.