ComfyUI Node

MS-SSIM

SSIM that bothered to look at more than one scale

By Laurent2916·Created about a year ago·Updated about a year ago· 0
MS-SSIM
  • image_a
  • image_b
  • kernel_size
  • ms_ssim
kernel_sigma1.50
data_range1.00
reduction
k10.01
k20.03

Plain SSIM scores one image at one resolution, which is a bit like judging a photograph from a single distance. MS-SSIM (Multi-Scale Structural Similarity) is the fix: it runs the SSIM machinery across five progressively downsampled versions of the image and combines the contrast comparisons from each scale with a final structure term at the smallest one. Higher is better, 1.0 is identical, and in the papers it consistently correlates with human opinion a little better than single-scale SSIM - especially when the two images you're comparing were rendered at different effective scales, which is basically every upscaler comparison you've ever seen.

It's one of the seventeen nodes in comfyui-piq, Laurent Fainsin's wrapper around the piq PyTorch library. Same pack pattern as the rest: image_a and image_b in, one FLOAT out, everything under the "piq" category. No weights, no downloads, runs in a few milliseconds on CPU.

How it works. The image gets repeatedly low-pass filtered and downsampled by 2 until you've got five scales. Each scale contributes a contrast comparison, and the finest scales' structure term and the coarsest scales' luminance term are multiplied together with the empirically-tuned weights from the original MS-SSIM paper. That's what makes it a single pooled score instead of five separate ones. The k1/k2 constants are the same stability constants SSIM uses - you won't touch them.

Inputs worth knowing:

  • data_range - leave at 1.0. ComfyUI hands you floats in 0–1 and piq needs to know the max value range or every score drifts.
  • kernel_size / kernel_sigma - 11 and 1.5, the canonical Gaussian window. Leave them.
  • reduction - mean is what you want for a single comparable number.
  • image_a / image_b - your candidate vs. your reference. image_b is the ground truth.

The ms_ssim output is a FLOAT in [0, 1]. A good pair of generations typically sits in the high 0.9s.

Installing. ComfyUI Manager, search "comfyui-piq", Install. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/Laurent2916/comfyui-piq.git
pip install -r custom_nodes/comfyui-piq/requirements.txt

The requirements file is one line: piq>=0.8.0, and the pack wants Python 3.12+. The repo is archived but these are frozen, stable metrics - that's fine.

The honest take. MS-SSIM is a genuinely better SSIM and still a traditional metric. It'll tell you which of two upscales kept more fine-scale structure intact, and it's less fooled by global shifts than PSNR. But it's still not perceptual: it has no idea what a face is, what text is, or what a rendering artifact looks like. Use it as the rigorous sidekick to SSIM when you're A/B testing upscalers or VAEs at different resolutions, and keep a learned metric (LPIPS, DISTS) in the graph when the question is "which one actually looks better." Traditional and learned metrics disagree all the time - that disagreement is information, not a bug.

Categorypiq

Inputs (8)

NameTypeDefaultDescription
image_aIMAGEInput image
image_bIMAGEReference image
kernel_sizeINTEGER11Size of the Gaussian kernel
kernel_sigmaFLOAT1.50Standard deviation of the Gaussian kernel
data_rangeFLOAT1.00Maximum value range of images
reductionCOMBOReduction method
k1FLOAT0.01First stability constant
k2FLOAT0.03Second stability constant

Outputs (1)

NameTypeDescription
ms_ssimFLOATMulti-Scale Structural Similarity Index