Nodes/Network Bending for ComfyUI/Latent Format Converter
ComfyUI Node

Latent Format Converter

The bridge between image latents and audio latents

By DavidPiazza·Created about a year ago·Updated 9 months ago· 0
Latent Format Converter
  • samples
  • samples
conversion_modeauto_detect
target_height64
target_width64
reshape_methodreshape
target_channels-1
channel_modeproject

Image latents are 4D tensors (batch, channels, height, width). Audio latents are 3D (batch, channels, length). They don't fit in the same sockets, and Latent Format Converter is the adapter that lets them talk. It's the node that powers the README's "cross-modal bending" promise - take an image model's latent, reshape it into an audio-shaped tensor, bend it with audio tools, and bring it back. Or just straight up run an image VAE's tricks on an audio latent. It's weird, it's experimental, and it's a lot of fun.

How it works

The node looks at the tensor's rank to figure out what it's dealing with - auto_detect does this for you - then reshapes with one of four reshape_methods:

  • reshape - brute-force reshape to the target height/width.
  • interpolate - resample spatially instead of just reindexing.
  • fold / tile - fold the length into a 2D grid, or tile a patch across it.

Channels are handled separately via channel_mode (project, pad, interpolate, or tile) toward target_channels. And this is where the tooltip earns its keep: -1 keeps the original channel count, 4 is SD, 64 is Stable Audio. Those are the two realities this node straddles - the SD image VAE's 4-channel latent and the Stable Audio VAE's 64-channel one. If you're converting audio→image, you'll set target_channels to 4 and pick your target_height/target_width; image→audio, you're probably heading back to 64.

The inputs that matter

  • samples - the LATENT to convert.
  • conversion_mode - audio_to_image, image_to_audio, or auto_detect. Let auto_detect do its thing until it annoys you.
  • target_height / target_width - the spatial size for audio→image conversion.
  • target_channels - 4 for SD, 64 for Stable Audio, -1 to leave alone.
  • reshape_method / channel_mode - the mechanical choices; reshape and project are the sensible defaults.

Output is a LATENT in the new shape.

Installing it

Ships in DavidPiazza/network_bending. ComfyUI Manager ("Network Bending") or:

cd ComfyUI/custom_nodes
git clone https://github.com/DavidPiazza/network_bending.git

Restart. No pip step for this one - it's pure torch tensor work.

Honest expectations

This node is fully implemented, but "converting" between latent spaces is not the same as "making the VAE agree with you." A 64-channel audio latent squeezed to 4 channels and decoded by an image VAE is going to look like an abstract painting, not a photograph - which is either the point or a warning, depending on your goals. The genuinely useful pattern is experimental: encode audio, convert to image format, run an image latent operation, convert back, decode as audio, and see what the resulting sound is. Treat the first several attempts as science experiments. And note the pack-wide caveat: it's version 0.0.1, some nodes are stubs, but the converter is one of the real ones.

Categorynetwork_bending

Inputs (7)

NameTypeDefaultDescription
samplesLATENTLatent samples to convert
conversion_modeCOMBOauto_detectConversion direction
target_heightINT648–512Target height when converting to image format
target_widthINT648–512Target width when converting to image format
reshape_methodCOMBOreshapeMethod for reshaping tensors
target_channelsINT-1-1–256Target number of channels (-1 to keep original, 4 for SD, 64 for StableAudio)
channel_modeCOMBOprojectMethod for converting channels

Outputs (1)

NameTypeDescription
samplesLATENTConverted latent samples