AlphaVAE Encode (RGBA)
Sending transparency back into the sampler
- image
- alpha
- alpha_vae
- samples
AlphaVAE Encode (RGBA) is the input-side half of the katsut/ComfyUI-AlphaVAE pack, and the one people forget exists. The pack's Decode node gets all the attention because it's where transparent cutouts finally appear. This node does the reverse: it takes an image and its alpha mask, packs them into a single RGBA tensor, and encodes them back into a latent - so you can run FLUX on top of an image while keeping the transparency in the loop.
If you've never felt the need for it, you've only been doing txt2img. Reach for this node the moment you want img2img on a transparent asset: regenerating a cutout with different composition but preserved edges, inpainting onto a transparent layer, or re-sampling an existing RGBA result instead of starting from noise. That's the same job a stock FLUX VAE encode does - except a stock VAE eats the alpha channel the instant it touches your image, because it only has three channels. This one keeps all four.
How it works
The mechanism is the mirror image of AlphaVAEDecode, and it's refreshingly boring. It concatenates your RGB image and your mask into one [B,H,W,4] tensor, reorders it to [B,4,H,W], rescales from [0,1] to the [-1,1] range the VAE expects, and runs the AlphaVAE encoder. The resulting latent is a standard LATENT that drops straight into KSampler, which applies its usual scaling - the node deliberately avoids double-scaling.
One subtlety worth knowing, because it's the kind of thing that produces mystifying round-trip results: Decode flips the alpha convention, Encode does not. On the way out, the pack inverts AlphaVAE's native 0-opaque/1-transparent output so you get a normal mask (1 = opaque). On the way in, this node takes your mask as-is, no inversion. So if you pipe a Decode output's alpha directly back into an Encode, you're feeding it the flipped convention, and a decode→encode→decode round trip will come back with the transparency inverted. When your own masks are in the standard 1 = opaque convention, keep them that way and don't expect the node to fix it for you.
Inputs and outputs
Three required inputs, one output:
image(IMAGE) - your RGB image, typically the output ofAlphaVAEDecode(for a re-sample) or a loaded RGBA PNG that's been split.alpha(MASK) - the transparency, 1 = opaque.LoadImagegives you a mask alongside the image for PNGs with alpha, so that's the usual source.alpha_vae(ALPHA_VAE) - the handle fromAlphaVAELoader.samples(LATENT) - the encoded latent, ready forKSampler.
The practical graph is short:
LoadImage (RGBA PNG) ──┬─→ AlphaVAEEncode → KSampler → ...
└─→ LoadImage mask
Installing it
Same pack, same steps as the others. ComfyUI Manager (search comfyui-alphavae), or:
cd ComfyUI/custom_nodes
git clone https://github.com/katsut/ComfyUI-AlphaVAE.git
pip install diffusers>=0.33.0
Restart after. Needs ComfyUI v0.18+ and diffusers 0.33+ (the project pins 0.38+ in pyproject.toml). And the full model stack - roughly 36 GB across flux1-dev.safetensors (~12 GB, HF license agreement), the AlphaVAE VAE folder (168 MB) in models/vae/AlphaVAE/finetune_VAE/, the required 1.3 GB diffusion LoRA in models/loras/, and the clip_l + t5xxl_fp8 encoders in models/clip/.
Common issues
- The latent encodes, but transparency comes back wrong on decode. Check your alpha convention (see above). If the mask came from the pack's own Decode output, you need to invert it before feeding Encode.
- Encode works, decode shows flat grey alpha. Still the missing LoRA. Encode can faithfully store whatever alpha you hand it, but the sampler has to be able to interpret it, and that requires the 1.3 GB diffusion LoRA loaded on the model and CLIP paths at strength 1.0. Without it, regeneration scrubs the transparency out of the latents.
- "Expected 4-channel VAE" from the loader. You selected a stock 3-channel VAE in
AlphaVAELoader. This node refuses to encode through it, correctly. - FLUX.2 latents in, errors out. By design - the weights are FLUX.1-dev-only, and the README says there's no FLUX.2 support planned.
Honest bottom line: this is the least glamorous node in the pack, and for most people it'll sit unused while Decode does the heavy lifting. But if you're building actual transparent-image workflows - assets, layers, compositing - it's the difference between generating one cutout and being able to rework cutouts. That's worth the 36 GB of downloads all by itself.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| alpha | MASK | — | |
| alpha_vae | ALPHA_VAE | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| samples | LATENT | — |