ComfyUI Node

LatentToHist

Look at the actual numbers inside your latent

By CYBERLOOM-INC·Created 3 years ago·Updated 2 years ago· 11
LatentToHist
  • samples
  • IMAGE
  • STRING
min_auto
min_value-5.00
max_auto
max_value5.00
bin_auto
bin_count10
ymax_auto
ymax1.00

Latents are just numbers - 4-channel tensors of floats - and most of the time you never see them, only their decoded result. LatentToHist makes the numbers visible: it plots a histogram of each of the latent's four channels and hands you the plot as an image, plus the raw histogram data as a CSV string. It's a debugging tool, and a genuinely handy one when a generation goes weird.

Inputs: samples (LATENT), then four pairs of *_auto / *_value toggles. Each toggle flips between Auto (compute from the actual data) and Specified (use the neighboring value field). You can pin the histogram's min/max range (min_value/max_value, defaults -5/+5), the number of bins (bin_count, default 10), and the plot's y-axis ceiling (ymax). Outputs: an IMAGE (the 512×512 matplotlib figure) and a STRING containing the raw CSV - channel, bin value, and density per row.

Mechanically it's matplotlib doing the plotting over torch.histogram - it normalizes each channel's counts by the total and plots all four channels (color-coded, one line each) with a legend. The CSV string output is the same data in text form, which makes it scriptable: you can pipe a latent's distribution into a text node and compare distributions across runs numerically instead of by eye.

The Auto/Specified design is the part to internalize. Auto is the safe default - it derives the range and binning from the actual tensor, so you always get a sensible-looking plot. Specified is for when you want to compare latents on the same fixed scale, like checking whether two sampling runs produced distributions that match. If you specify a range and your data lives outside it, the histogram just clips it - the plot won't error, but you'll see data piled against the edges.

Install via ComfyUI Manager (search "ComfyUI-nodes-hnmr") or:

cd ComfyUI/custom_nodes
git clone https://github.com/CYBERLOOM-INC/ComfyUI-nodes-hnmr

Restart ComfyUI. One real dependency: it needs matplotlib (the code raises a clear LatentToHist requires matplotlib error if it's missing). ComfyUI's venv usually has it, but if you hit that error:

pip install matplotlib

When would you actually use this? It's niche. A few people use it to sanity-check img2img or inpainting latents (are my channels collapsing to a narrow range?), and it's a nice teaching tool for understanding what a latent is. But for 95% of workflows, decoding the latent and looking at the image tells you more. Reach for it when "it's just wrong" and you want to verify the latent space itself, not the decoder. As with the rest of this pack, install the CYBERLOOM-INC fork - the original stopped getting fixes and broke on modern ComfyUI.

Categorylatent

Inputs (9)

NameTypeDefaultDescription
samplesLATENT
min_autoCOMBO2 options: Auto, Specified
min_valueFLOAT-5.00-100–0
max_autoCOMBO2 options: Auto, Specified
max_valueFLOAT5.000–100
bin_autoCOMBO2 options: Auto, Specified
bin_countINT103–1000
ymax_autoCOMBO2 options: Auto, Specified
ymaxFLOAT1.000.01–1

Outputs (2)

NameTypeDescription
IMAGEIMAGE
STRINGSTRING