Nodes/ComfyDL/Image Stats
ComfyUI Node

Image Stats

What's actually inside that image tensor? Just ask it

By Cynthia-lxx·Created 2 months ago·Updated 2 days ago· 6
Image Stats
  • image
  • stats

CdlImageStats is a debug tool with a single job: read the numbers out of an image tensor and show them to you. Feed it an IMAGE and it reports, per channel, the mean, standard deviation, min, and max across the whole batch, plus a summary line with the batch count, dimensions, and channel count. That's it. No pixels are changed, nothing is transformed - you get a STRING and you go look at it.

This is the node you reach for when an image looks wrong and you need to know why numerically. ComfyUI images are float32 tensors nominally in [0, 1], but plenty of nodes violate that - most notably ComfyDL's own Image Normalize, which deliberately outputs un-clipped z-scores. Feed a normalized tensor into a preview and it looks black and blown out; feed the same tensor into CdlImageStats and you'll see mean ≈ 0, std ≈ 1, min < 0, and suddenly everything makes sense. Same story with an upscaler that quietly pushes values past 1.0. When pixels misbehave, this node is how you catch the tensor lying to you.

How it works

It's a thin loop over the channel dimension: for each channel it computes mean, std, min, and max on the whole batch at once, then appends a batch-layout line. Because the stats aggregate over every image in the batch, it's honest about the whole set, not just one frame. The result is a plain multi-line string.

Input and output

There's exactly one input - image, any IMAGE. The single output is stats, a STRING, which you should wire into a text display node to actually see (or right-click the output if you're on a frontend that shows it). The output looks like:

channel 0: mean=0.493142 std=0.246001 min=0.000000 max=1.000000
...
batch: 4 images, 512x512 px, 3 channels

Watch the std line especially: after Image Normalize with the default 0.5,0.5,0.5, you should see std near 1 and min below 0. That's your confirmation the z-score math ran, and your reminder not to preview it directly.

Installing ComfyDL

It's part of the ComfyDL pack:

cd ComfyUI/custom_nodes
git clone https://github.com/Cynthia-lxx/ComfyDL
pip install -r ComfyDL/requirements.txt

Restart ComfyUI. The only extra dependency is matplotlib; torch and torchvision ship with ComfyUI. ComfyUI Manager users: search "ComfyDL", and if it's missing from the built-in list (the pack isn't on the official registry yet), use Install via Git URL with the repo link.

Common issues

The main annoyance is that a STRING output doesn't display itself - if you leave the output unwired, on many frontends you won't see the text at all. Wire it to a text/preview node. And remember the stats are batch-wide: if you have 16 frames and one is anomalous, the mean will hide it while min/max will catch it. If a value like mean or min is exactly 0.5/0.0 every time, that's a strong hint something upstream is clipping to a fixed range - which is precisely what this node exists to reveal.

Categoryimage

Inputs (1)

NameTypeDefaultDescription
imageIMAGE

Outputs (1)

NameTypeDescription
statsSTRING