VAE Encode New
The encoder that skips work when nobody's home
- pixels
- vae
- LATENT
VAE Encode New is the stock ComfyUI VAE Encode with one extra input bolted on: a boolean called has_face. When that boolean is False, the node skips the actual encode entirely and hands you a blank latent. That sounds like a party trick, but it's the whole point - this node exists to make a conditional face workflow run fast on images that don't have a face in them.
Here's the context. This node ships in the upseem/comfyui_sunxAI_facetools pack (by Sunx.ai), which is built around InstantID-style identity work: detect a face, hold its identity, refine or restore it. In those workflows you're often processing a whole batch of images, and only some of them contain a face. If your graph unconditionally runs an expensive VAE encode + refine pass on every frame, you're burning GPU cycles on hundreds of empty portraits. VAE Encode New gives you a clean way to short-circuit that branch.
How it works. The mechanism is embarrassingly simple. Feed it pixels (IMAGE) and vae (VAE), same as the stock node. If has_face is True, it does a normal vae.encode() and returns the LATENT. If it's False, it returns a latent of zeros shaped [1, 4, 64, 64] - which is exactly a 512×512 image at 8× VAE compression - without touching the VAE at all. You wire has_face from the pack's face-detection node (DetectFaceByIndex outputs exactly that boolean), and the whole downstream chain keeps running with a dummy latent instead of crashing or stalling.
The inputs that matter. Just three, and only one is interesting:
pixels- the image to encodevae- your VAEhas_face(optional, defaults True) - the gate. Leave it unwired and the node behaves like stock VAE Encode.
Where people get burned. The blank latent is a real latent, not a sentinel that downstream nodes understand. If it flows into a KSampler, the sampler will happily generate noise-and-garbage from it. The intended pattern is that you gate the heavy nodes with the same has_face signal (via SelectFloatByBool, or by only wiring the refine branch when a face exists), so the blank latent only ever feeds into things that are equally blanked out. Treat the blank latent as a way to keep the graph acyclic, not as an image of anything.
Install. It's part of a pack, so you install the whole thing: in ComfyUI Manager search for comfyui_sunxAI_facetools (or the author name Sunx.ai), hit install, restart. Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/upseem/comfyui_sunxAI_facetools
then restart ComfyUI. Fair warning: the pack's dependency list is heavy - insightface, onnxruntime, ultralytics, mediapipe, transformers, and friends. ComfyUI Manager will try to handle it, but InsightFace in particular has a well-earned reputation for being painful to install on Windows, and it auto-downloads its own models on first use. If your workflow never actually calls the gender-detection code, you could in principle dodge some of that, but the pack's requirements install it regardless.
In a batch pipeline, this node is the difference between "90% of my run is wasted work" and "90% of my run is a no-op." It's a small node that quietly does a lot of work.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| pixels | IMAGE | — | |
| vae | VAE | — | |
| has_faceopt | BOOLEAN | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| LATENT | LATENT | — |