Nodes/saya-comfy-couple-plus/Saya Latent Shape From Image
ComfyUI Node

Saya Latent Shape From Image

A latent that only knows its own shape — for rebuilding masks without a VAE

By alphaziod·Created 3 months ago·Updated about 15 hours ago· 3
Saya Latent Shape From Image
  • image
  • latent_shape

SayaLatentShapeFromImage does one deceptively useful thing: feed it an image and it hands you back an empty latent with exactly that image's dimensions. No VAE encode, no model loaded, nothing sampled - it measures the image and builds a zero tensor of the right size. The output is a LATENT whose samples are all zeros at [batch, 4, H/8, W/8].

Why would you want an empty latent of the correct size? Because several things in the Saya pack - the couple/regional-attention machinery in particular - compute their spatial masks from a latent's dimensions, not from its contents. The pack's phase-isolated pipeline breaks this: each pass runs as its own prompt, and a later phase may only have a decoded PNG to look at. There's no latent to measure, and running a VAE encode just to learn the resolution is a waste of VRAM and time. This node is the shortcut: look at the image, hand the downstream mask/regional code a latent shaped like the canvas it expects.

That's also the boundary you must respect. This is a geometry template, not content. It says so in the source - "a zero latent carrying only an image's shape, so couple masks can be rebuilt for a later phase." The masks and the regional attention care about dimensions; they do not care that the latent is empty. But if you grab the output and wire it somewhere that expects real latent content - a second-stage sampler that would resample it, say - you are giving it a black void and you will get garbage or worse, a silent bad result. Use it where a shape is the requirement, not where pixels need meaning.

Practical details worth knowing:

  • The compression is hardcoded at 8× (H/8, W/8) with 4 channels - the SDXL-style latent geometry this pack's masking is built around. If your pipeline's actual VAE uses a different compression ratio, the mask grid this latent implies won't line up with your sampler's latent space. For the pack's own duo/couple flows it matches; outside them, check.
  • The input must be a real IMAGE tensor with batch/height/width/channels. Give it anything else and the node raises a ValueError rather than guessing - that's by design.
  • It's fast because it does nothing. There is no VAE in this node. If you see it in a workflow and wonder where the encode step went, that's the answer: there isn't one.

It lives in the Saya/Image Phases corner of the pack (category: saya/image phases), and like everything here you install it with the shared pack: ComfyUI Manager search saya-comfy-couple-plus, or

cd ComfyUI/custom_nodes
git clone https://github.com/alphaziod/saya-comfy-couple-plus

then restart ComfyUI. Dependencies are only numpy and Pillow; no models download. The pack's README covers the Comfy Couple side of the house and says nothing about this node, and the code carries the author's usual WIP caveat - ports can move between versions, so re-save workflows after updating.

This is the sort of node that looks pointless until you're debugging a regional workflow that silently lost its masks three phases ago, at which point it's exactly the missing link. Keep it in mind as a shape probe: any node downstream that only needs to know "how big is this canvas" can be satisfied without touching a VAE.

Categorysaya/image phases

Inputs (1)

NameTypeDefaultDescription
imageIMAGE

Outputs (1)

NameTypeDescription
latent_shapeLATENT