Qwen-Image-Layered Control Decomposition
Describe the elements you want in the image and decompose it precisely from the image.
About
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.
What you provide
- Reading the workflow
Runs in ComfyUI. This workflow can't run on this page. Open it in Comfy Cloud with everything loaded, or download it for your own ComfyUI.
Try in CloudInside the workflow
A read-only preview of the node graph. Open it in Comfy Cloud or download it to edit the nodes.
Loading the graph
Open full-size workflow preview- Author
- ComfyUI
Requires custom nodes
- Reading the workflow
Use this workflow from code
Generated from the workflow graph and inputs when possible; stored examples are shown otherwise. Review credentials and endpoints before running code, which may incur charges.
What you need
- Runs on
- Comfy Cloud
- Key
- COMFY_API_KEY
Needs a paid Cloud plan and credits.
# 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)Questions & answers
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.