ComfyUI Node

MSGMSD

GMSD, now with the multi-scale brain

By Laurent2916·Created about a year ago·Updated about a year ago· 0
MSGMSD
  • image_a
  • image_b
  • msgmsd
data_range1.00
reduction
chromaticfalse
alpha0.50
beta10.01
beta20.32
beta315.00
t170.00

Take GMSD's clever insight - score the deviation of a gradient-magnitude similarity map instead of its average - and run it across multiple downsampled scales, and you get MSGMSD. It inherits GMSD's quirk too, so get this straight before anything else: lower is better. 0.0 is pixel-identical, and like GMSD, a smaller score means the reproduction is more consistent and faithful. Invert that in your head and you'll wire the node backwards the first time. I did.

It's one of the seventeen nodes in comfyui-piq, Laurent Fainsin's wrapper around the piq library. Same pack pattern: image_a and image_b in, one FLOAT out, "piq" category, no model downloads.

How it works. MSGMSD computes gradient-magnitude similarity at several scales - the multi-scale structure that makes MS-SSIM strong - and combines them with a scale-weighting parameter (alpha, default 0.5) so fine scales and coarse scales don't get equal say. The score is still a deviation, so it punishes local inconsistency: an image that's faithful in the corners and wrecked in the middle scores worse than one that's uniformly mediocre, which is exactly the failure mode you want a metric to catch. The three beta constants and t are regularization values from the paper, and chromatic (default false) adds a color channel comparison to get MSGMSDc.

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.
  • chromatic - flip to true if color fidelity matters to you.
  • reduction - mean.
  • alpha, beta1beta3, t - paper defaults, leave them.

The msgmsd output is a FLOAT, lower better, usually in the ~0.0–0.3 range for realistic comparisons.

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 entire requirements file; Python 3.12+; repo archived but the metric is frozen in place and fine to use.

The honest take. MSGMSD is the multi-scale upgrade for people who already trust GMSD - same sensibility, more sensitivity to scale-dependent artifacts, which is the scenario you're actually in when comparing upscaler outputs at different resolutions. If you're picking between the two, MSGMSD is the better measurement and only modestly slower. Just remember which way the number goes, and keep a learned metric in the loop when the question is taste rather than fidelity.

Categorypiq

Inputs (10)

NameTypeDefaultDescription
image_aIMAGEInput image
image_bIMAGEReference image
data_rangeFLOAT1.00Maximum value range of images
reductionCOMBOReduction method
chromaticBOOLEANfalseWhether to include color features
alphaFLOAT0.50Scale weighting parameter
beta1FLOAT0.01First regularization parameter
beta2FLOAT0.32Second regularization parameter
beta3FLOAT15.00Third regularization parameter
tFLOAT170.00Regularization constant

Outputs (1)

NameTypeDescription
msgmsdFLOATMulti-Scale Gradient Magnitude Similarity Deviation