Nodes/ComfyUI-Inference-Core-Nodes/[Inference.Core] Layer Diffuse Decode
ComfyUI Node

[Inference.Core] Layer Diffuse Decode

Turning the sampled latent into a real transparent PNG

By LykosAI·Created 2 years ago·Updated about a year ago· 33
[Inference.Core] Layer Diffuse Decode
  • samples
  • images
  • IMAGE
  • MASK
sd_versionSDXL
sub_batch_size16

Every Layer Diffuse graph ends here. Inference_Core_LayeredDiffusionApply (or one of its siblings) patches your model to secretly encode transparency into the latent during sampling - but a sampled latent isn't a usable image yet, and ComfyUI has no native RGBA image type to smuggle a transparency channel through. Decode is the node that solves both problems at once: it pulls the hidden alpha information back out and hands it to you as a standard ComfyUI MASK, alongside the normal IMAGE.

Why it needs two inputs, not one

The two required inputs are samples (the raw LATENT from your sampler) and images (an IMAGE) - and it's easy to assume images is optional or redundant, but it isn't. Layer Diffuse's transparency decoder doesn't purely read the latent; it also needs the conventionally-VAE-decoded RGB pixels of that same generation to correctly place where the alpha boundary sits. So the actual graph shape is: sample as normal, run a regular VAE Decode on the result to get images, then feed both that decoded image and the original latent (samples) into this node together. Feeding it an unrelated image instead of the matching VAE-decoded output won't error, but it also won't give you a meaningful mask.

sd_version (SD15 or SDXL, default SDXL) has to match whichever config you used back at the Apply stage - the two architectures use different learned decoders, and mismatching them is the single most common way this node produces garbage. sub_batch_size (1–4096, default 16) is purely a VRAM control: it chunks the decode into groups of this many images at a time. Leave it at the default unless you're decoding a large batch and running low on memory, in which case drop it (try 8, then 4) at a small cost to speed.

Outputs

  • IMAGE - the RGB portion of the result.
  • MASK - the recovered alpha channel.

From here, feed MASK into whatever your workflow needs: a straight Save Image with alpha support, a composite against a new background, or a "Convert Mask to Image" node if you want to inspect it directly. The two outputs together are your transparent result - ComfyUI just represents it as two separate tensors instead of one four-channel image.

Installing it

Ships with the pack, no separate download. ComfyUI Manager: search "ComfyUI-Inference-Core-Nodes". Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/LykosAI/ComfyUI-Inference-Core-Nodes

then install.py, or pip install -e .[cuda] (or the [cuda12] / [rocm] / [directml] / [cpu] variant) and restart. If Apply already downloaded its Hugging Face conversion weights successfully, Decode uses the same cache - nothing extra to fetch.

Where it breaks

An all-black or fully-opaque mask is almost always one of two things: sd_version doesn't match the config used at Apply time, or images isn't actually the VAE-decoded output of the same samples you're feeding in - a leftover image from earlier in the graph, or an image loaded from disk, will not work. Trace both inputs back to a single sampling pass before assuming the technique itself is broken.

If you generated multiple layers together through one of the Joint Apply nodes rather than a single transparent layer, you want Inference_Core_LayeredDiffusionDecodeSplit instead - plain Decode expects one layer per batch entry, not a packed multi-layer batch.

Categorylayer_diffuse

Inputs (4)

NameTypeDefaultDescription
samplesLATENT
imagesIMAGE
sd_versionCOMBOSDXL2 options: SD15, SDXL
sub_batch_sizeINT161–4096

Outputs (2)

NameTypeDescription
IMAGEIMAGE
MASKMASK