Image Batch to Latent
The Other Half of Latent Channel Surgery
- image_batch
- latent
Latents are opaque. You can't look at one, edit a channel in Photoshop, and put it back - unless you have a node that converts latent channels into images and another that converts them back. Image Batch to Latent is the "back" half. It takes a batch of grayscale images (each one representing a latent channel, exactly like the pack's "Latent to Image Batch" node produces) and stacks them back into a LATENT tensor. That round-trip is the entire point: inspect channels visually, tweak them in an editor, reimport.
It's a debug/round-trip tool, and it's honest about that - it lives under latent/debug, not anywhere glamorous. Where it shines is workflows where you've split a latent into per-channel images, done something to them (denoised one channel, sharpened another), and now need a valid latent again without hand-rolling a tensor reshape in Python.
How it works
The input batch is interpreted as batch_size × channels grayscale images. The node pulls a single channel from each RGB image (your choice of r, g, or b, or mean of all three), then reshapes the flattened stack into (batch_size, channels, H, W). The only real math is getting the batch/channel split right, and the node will infer it for you if you leave one of the two at 0 - it figures out the other from the total image count.
The inputs that matter
image_batch- the stack of per-channel images.batch_size/channels- set one, leave the other at0to infer. The product of the two must equal the number of images in the batch.channel_source- which RGB channel to treat as the grayscale value (r/g/b/mean). Matters if your images aren't truly grayscale.
Output is a single latent (LATENT) with shape (batch, channels, H, W).
Installing it
It's part of Skoogeer-Noise. Manager → search "Skoogeer-Noise", or:
cd ComfyUI/custom_nodes
git clone https://github.com/ttulttul/Skoogeer-Noise
Restart ComfyUI. Deps are torch, numpy>=1.26, einops, pyyaml>=6.0.3 - all standard, no model files to fetch.
Common gotchas
The classic failure is a reshape error because batch_size * channels doesn't match the image count. If you're hand-feeding images, count them. Also be careful with channel_source: if you saved your channels as proper grayscale, the RGB channels are identical and it doesn't matter, but if anything re-expanded them into a color image, pick the channel that actually holds your data. And temper expectations - this is a lossless-ish reconstruction of the channel layout, not a magic way to make an arbitrary image into a latent that samples meaningfully. It round-trips channels, not semantics.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| image_batch | IMAGE | Batch of images representing latent channels. | |
| batch_size | INT | 00–4096 | Original latent batch size (0 to infer from channels). |
| channels | INT | 00–4096 | Channel count per latent sample (0 to infer from batch_size). |
| channel_source | COMBO | r | Which channel to use from RGB inputs (mean averages channels). |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| latent | LATENT | — |