Nodes/ComfyUI-QwenImageLayered/QwenImage Layered V2 Decompose
ComfyUI Node

QwenImage Layered V2 Decompose

Pull one RGBA layer out of a flat image — and mind the brush

By bambom·Created 4 months ago·Updated 4 months ago· 0
QwenImage Layered V2 Decompose
  • pipeline
  • image
  • context_image
  • target_mask
  • remove_mask
  • layer_image
prompt
seed0
steps10
cfg_scale1.0
width1024
height1024
layer_num0
use_input_sizetrue
negative_prompt

This is the node that actually does the thing: it takes your image, runs the Qwen-Image-Layered V2 pipeline from the QwenImage Layered V2 Loader, and returns one isolated RGBA layer. Think of Layered as the model that finally gives raster images the thing LayerDiffusion could only fake on SDXL - native alpha that doesn't have to be matted out afterward. Every layer you pull becomes a PNG with its own transparency, which you can composite, re-prompt, or re-light without touching the rest of the picture.

The honest caveat up front, because the README leads with it: the context_image brush is soft conditioning, not a hard inpaint mask. It steers what the model pulls, it does not guarantee a pixel-exact extraction. If the output crops, redraws, or wanders off your brush region, that's a known limitation of this route, not a bug in your workflow. For precision work, masked inpainting still owns bit-identical pixels; this is for getting a separated element - foreground, background, a poster's text layer - out with real alpha.

How it works

The node resizes your input to the model's working size (rounded to a multiple of 16), builds or receives the RGBA context_image, and calls DiffSynth's pipeline with layer_input_image, layer_num, and the context. It returns a single layer_image - RGBA, so the alpha channel is right there - which you feed to a Preview or Save node. Want the background instead of the subject? Run it again with the layers flipped. That's the "recursive decomposition" trick: each call extracts one layer, and you can chain them until everything's separated.

The inputs that matter

  • prompt - describe the whole image, like you're captioning it. Do not write "cut out", "isolate layer", "mask" or any extraction instruction; the brush already tells it what to pull, and cutting language makes it fight you.
  • steps (default 10) and cfg_scale (default 1.0). The README's recipe: start at 10 steps, bump them when occlusion gets complex, and keep cfg_scale at 1.0 when a brush is attached - it trusts the brush more that way.
  • layer_num (default 0) - which layer in the stack to extract. 0 is the usual starting point; bump it when you want the next layer up.
  • use_input_size (default True) - keeps your image's aspect ratio and current size. Turn it off and width / height (both default 1024, stepped by 16) become the manual output size.
  • seed - same seed, same layer, useful when you're hunting for a good pull.

Optionally it also takes negative_prompt, context_image, and the raw target_mask / remove_mask - if you skip the Brush Context node entirely, you can wire masks straight in here and it builds the RGBA context internally. Either connection style works.

The trap: red vs green

The brush context encodes intent by color: red means "extract this", green means "exclude this", and where both overlap you get yellow - the occluded back layer that sits behind your target. The classic failure is output that looks like it dug a hole where you brushed. That means your target region landed in the green channel (or the model read it backwards). Before re-running a 10-step sample, plug the Brush Context output into a PreviewImage and check: is your region red? If not, flip invert_target on the Brush Context node. Cheap to check, expensive to guess.

One more tip: use_input_size is on by default, so a small input image stays small through the pipeline. If your layer comes out blocky, upscale the input before decomposing rather than reaching for width/height - the model works better on bigger source frames.

CategoryQwenImageLayered/V2

Inputs (14)

NameTypeDefaultDescription
pipelineQWEN_LAYERED_V2_PIPELINE
imageIMAGE
promptSTRING
seedINT00–18446744073709550000
stepsINT101–100
cfg_scaleFLOAT1.00–20
widthINT1024256–4096
heightINT1024256–4096
layer_numINT00–32
use_input_sizeBOOLEANtrue
negative_promptoptSTRING
context_imageoptIMAGE
target_maskoptMASK
remove_maskoptMASK

Outputs (1)

NameTypeDescription
layer_imageIMAGE