PSNR
The boring metric that catches real breakage
- image_a
- image_b
- psnr
PSNR is the unglamorous workhorse of image metrics, and in a ComfyUI workflow it answers one boring but essential question: did your pipeline actually corrupt the image, or just shuffle pixels? Peak signal-to-noise ratio compares two images pixel by pixel and reports the ratio in decibels. Higher is better. It has zero opinion about aesthetics, faces, or composition - which is exactly why it's the right tool when you want to know if a VAE decode, a latent round-trip, or an upscaler is silently mangling your data.
It ships in comfyui-piq, Laurent Fainsin's wrapper around the photosynthesis-team/piq library. Every node in the pack follows the same pattern: two IMAGE inputs, one FLOAT out, all under the "piq" category. PSNR is the simplest of the seventeen, and the only one that's genuinely free - it's closed-form math, no neural network, no weights to download.
How it works. PSNR is just mean squared error re-expressed on a log scale: 10 * log10(data_range² / MSE). The "peak signal" is the data_range - the maximum possible pixel value. That's why the default of 1.0 matters here: ComfyUI hands IMAGE tensors around as floats in 0–1, so 1.0 is correct. Feed it 0–255 ints with data_range left at 1 and every score will be nonsense. The only input you'll realistically touch besides the two images:
reduction-meangives one averaged score per image,sumadds up the per-pixel contributions (usually only useful if you're building your own reduction downstream).convert_to_greyscale- flips both images to YIQ and scores only the luminance channel, which matches how the broadcast world used PSNR. Nice for checking compression artifacts on grayscale-ish content, but most of us leave it off.
image_a is the image you're evaluating, image_b is the reference/ground truth you're comparing against. Get that backwards and your "before/after" graph lies to you. The output psnr (a single FLOAT) is in dB - for reference, a clean 0–1 float image compared to a barely-visibly-distorted copy lands around 30–40 dB. Anything below ~20 dB and something is genuinely broken.
Installing. Via ComfyUI Manager, search "comfyui-piq" and hit Install; or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/Laurent2916/comfyui-piq.git
pip install -r custom_nodes/comfyui-piq/requirements.txt
On Windows the pip line becomes .\python_embeded\Scripts\pip.exe install -r .\ComfyUI\custom_nodes\comfyui-piq\requirements.txt. The requirements file is a single dependency: piq>=0.8.0, so it installs fast. Note the repo needs Python 3.12+ and the original is now archived - it still works, just don't expect updates.
The trap. PSNR is great for catching corruption and nearly useless for judging quality. A heavily upscaled image can score lower than a clean blurry one, and two images that look identical to you can differ by several dB. Pair it with a perceptual metric rather than trusting it alone - that's the same lesson the community keeps relearning in every upscale shootout where someone's "winner" was just the misconfigured entrant. Use PSNR as your sanity check, not your arbiter.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| image_a | IMAGE | Input image | |
| image_b | IMAGE | Reference image | |
| data_range | FLOAT | 1.00 | Maximum value range of images |
| reduction | COMBO | Reduction method | |
| convert_to_greyscale | BOOLEAN | false | Convert images to YIQ format and compute PSNR only on luminance channel |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| psnr | FLOAT | Peak Signal-to-Noise Ratio |