ComfyUI Node

MDSI

Three cheap signals fused into one strong score

By Laurent2916·Created about a year ago·Updated about a year ago· 0
MDSI
  • image_a
  • image_b
  • mdsi
data_range1.00
reduction
c1140.00
c255.00
c3550.00
combination
alpha0.60
beta0.10
gamma0.20
rho1.00
q0.25
o0.25

MDSI (Mean Deviation Similarity Index) is what you get when you stop trusting any single visual signal and fuse three of them: gradient magnitude similarity, gradient similarity (direction, not just strength), and chromaticity. It's a classic "belt and suspenders" metric - none of the three components is fancy, but combined they beat most single-signal metrics in the benchmarks, and it does it all with plain math. Higher is better, 1.0 identical. It's one of the better traditional metrics in the pack that almost nobody has heard of.

It's a node in comfyui-piq, Laurent Fainsin's wrapper around the piq library. Same shape as the rest: image_a/image_b in, one FLOAT out, "piq" category, no model downloads.

How it works. Three local similarity maps are computed: how well the gradient magnitudes match, how well the gradient directions match, and how well the color (chromaticity) matches. These get combined with the fusion weights alpha, beta, and gamma (defaults 0.6/0.1/0.2 - note they don't sum to 1; they're tuned, not normalized), using either a sum or a product combination (combination). The combined map is then pooled into the final score with the deviation-flavored pooling parameters rho, q, and o - the same "don't let local damage hide in an average" instinct that makes GMSD good. The c1/c2/c3 constants are the usual stability constants.

Inputs a beginner actually sets:

  • image_a / image_b - candidate vs. reference; image_b is ground truth.
  • data_range - 1.0 for ComfyUI's 0–1 floats.
  • reduction - mean.
  • combination - sum (default) vs. mult; test both if you're curious, sum is the paper's choice.
  • Everything else - c1c3, alpha/beta/gamma, rho, q, o - leave at defaults.

The mdsi output is a FLOAT, roughly [0, 1], higher better.

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

piq>=0.8.0 is the whole requirements file; Python 3.12+; repo archived but stable.

The honest take. MDSI is a workhorse, not a star. It won't beat LPIPS on taste and it won't beat GMSD on speed, but it's a strong, well-rounded reference metric that's sensitive to both structural and directional distortion - the kind of thing that catches rotation/shear artifacts that pure magnitude metrics miss. It's a good second opinion when you're comparing upscale candidates and the usual suspects disagree.

Categorypiq

Inputs (14)

NameTypeDefaultDescription
image_aIMAGEInput image
image_bIMAGEReference image
data_rangeFLOAT1.00Maximum value range of images
reductionCOMBOReduction method
c1FLOAT140.00First regularization constant
c2FLOAT55.00Second regularization constant
c3FLOAT550.00Third regularization constant
combinationCOMBOCombination method
alphaFLOAT0.60First weighting parameter
betaFLOAT0.10Second weighting parameter
gammaFLOAT0.20Third weighting parameter
rhoFLOAT1.00Exponential parameter
qFLOAT0.25Pooling parameter
oFLOAT0.25Exponent parameter

Outputs (1)

NameTypeDescription
mdsiFLOATMean Deviation Similarity Index