Nodes/ComfyUI-productfix/VQ decoder diffusers (middlek)
ComfyUI Node

VQ decoder diffusers (middlek)

Decode VQ latents back to pixels, without the VAE round-trip

By MiddleKD·Created 2 years ago·Updated about a year ago· 21
VQ decoder diffusers (middlek)
  • vq
  • latents
  • IMAGE

VQDecoder closes the loop on the pack's VQ codec: it takes quantized latents (from VQEncoder, or from latent-space composition) and turns them back into an image you can actually look at. It's the mirror image of the encoder - same diffusers VQModel, same device juggling, opposite direction.

How it works

It grabs the samples out of the latent dict, moves them to the compute device, and calls vqmodel.decode(latents, force_not_quantize=True)["sample"]. That force_not_quantize=True is the interesting bit: it tells the decoder not to re-quantize the input before decoding, which matters when your latents have been edited - blended, injected, or otherwise transformed - and you don't want a second quantization step eating the changes. Then it denormalizes from [-1,1] back to [0,1], clamps, permutes to B,H,W,C, and returns a standard IMAGE.

The inputs and output

  • vq - the VQ model from VQLoader.
  • latents - a LATENT dict. Accepts either the encoder's output or a modified latent.
  • Returns an IMAGE, ready for preview, save, or upscaling.

Install

Same pack drill:

cd ComfyUI/custom_nodes
git clone https://github.com/MiddleKD/ComfyUI-productfix
pip install -r requirements.txt

Restart. diffusers and a loaded VQ model required; no downloads.

Gotchas

  • Pairs with VQEncoder, not with the SD VAE. If you try to decode regular VAE-encoded samples with this, you'll get garbage - the codecs are different models with different latent spaces.
  • Resolution behavior differs from the VAE. VQ decoders have their own scaling between latent and pixel space; don't assume the same latent→image ratios you're used to.
  • Clipping is final - output is clamped to [0,1], so if you overdrive a latent blend, the decoder clips instead of warning you.

Real talk: this node exists because the pack's author built a Kandinsky-style composition path and needed a decoder that wasn't the SD VAE. If you landed here without the VQ composition use case, you can skip it. But if you're deep in that path, it's the only thing that'll turn your composed quantized latents back into a product image - and it does it without drama.

Categoryproductfix

Inputs (2)

NameTypeDefaultDescription
vqVQ
latentsLATENT

Outputs (1)

NameTypeDescription
IMAGEIMAGE