Latent Format Converter
The bridge between image latents and audio latents
- samples
- samples
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- theLATENTto convert.conversion_mode-audio_to_image,image_to_audio, orauto_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;reshapeandprojectare 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.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| samples | LATENT | Latent samples to convert | |
| conversion_mode | COMBO | auto_detect | Conversion direction |
| target_height | INT | 648–512 | Target height when converting to image format |
| target_width | INT | 648–512 | Target width when converting to image format |
| reshape_method | COMBO | reshape | Method for reshaping tensors |
| target_channels | INT | -1-1–256 | Target number of channels (-1 to keep original, 4 for SD, 64 for StableAudio) |
| channel_mode | COMBO | project | Method for converting channels |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| samples | LATENT | Converted latent samples |