Nodes/ComfyUI-StyleGan/Blend StyleGAN Latents (lerp or slerp)
ComfyUI Node

Blend StyleGAN Latents (lerp or slerp)

Morphing faces with lerp and slerp

By spacepxl·Created 2 years ago·Updated 2 years ago· 21
Blend StyleGAN Latents (lerp or slerp)
  • latent_1
  • latent_2
  • STYLEGAN_LATENT
blend0.500
mode

Latent interpolation is the classic GAN party trick, and Blend StyleGAN Latents is the node that does it cleanly. Give it two latents and a blend factor, and it walks one face into another - the famous morphing videos that were all over the internet years before diffusion models made everyone forget GANs existed. Feed it a sequence of blend values and you can bake a perfectly smooth transition clip.

lerp vs slerp - the actual choice

Two modes, and the difference genuinely matters:

  • slerp (spherical interpolation) - the default listed first, and the one you'll use most. It interpolates along the surface of a high-dimensional sphere, keeping the intermediate vectors at a consistent magnitude. The result stays inside the region of latent space where faces look like faces - no freaky detours mid-morph.
  • lerp (linear interpolation) - a straight line between the two vectors in plain Euclidean space. It's the simple torch.lerp path: faster, and mathematically fine, but a straight chord can dip through regions where the decoder gets confused, so you'll occasionally see warped intermediate frames.

For anything you're going to show anyone, slerp. For quick procedural experiments where speed matters more than smoothness, lerp is fine. The node's slerp implementation is the well-trodden Birch-san gist adapted to PyTorch, and it handles edge cases (zero vectors, near-collinear vectors) by falling back to lerp, so it won't blow up on you.

The inputs that matter

  • latent_1, latent_2 - two STYLEGAN_LATENTs. They must share a shape; the node raises a clear error if they don't. In practice that means same model, same batch width.
  • blend - default 0.5, range -10 to 10, step 0.001. 0 gives latent_1, 1 gives latent_2. Here's the fun part: the range extends past both ends, so negative or >1 values extrapolate - exaggerating the difference between the two faces instead of converging. Turn one face "more catlike" by blending toward a cat latent with a factor of 1.5. It's a legitimate feature, not a bug.
  • mode - the slerp/lerp toggle above.

Output is a single STYLEGAN_LATENT at the blend position - same shape as the inputs - which feeds straight into StyleGAN Sampler.

Where it shines

Two faces from Generate StyleGAN Latent + a handful of blends at 0.1 steps = an 11-frame morph. Chain that across two seeds and you've got the skeleton of an animation. Or use it as a dial: blend a face toward the Batch Average latent to pull it back toward generic, or away from it to push features to extremes. The node sits in the StyleGAN/extra category, which is the pack's polite way of saying "utility for people who already have latents to play with" - but it's arguably the most fun node in the whole pack once you're past the install.

CategoryStyleGAN/extra

Inputs (4)

NameTypeDefaultDescription
latent_1STYLEGAN_LATENT
latent_2STYLEGAN_LATENT
blendFLOAT0.500-10–10
modeCOMBO2 options: slerp, lerp

Outputs (1)

NameTypeDescription
STYLEGAN_LATENTSTYLEGAN_LATENT