ComfyUI Node

GMSD

The devious little metric that outranks SSIM

By Laurent2916·Created about a year ago·Updated about a year ago· 0
GMSD
  • image_a
  • image_b
  • gmsd
data_range1.00
reduction
t0.00

Here's the twist that trips everyone up the first time: GMSD (Gradient Magnitude Similarity Deviation) is a deviation, so lower is better. 0.0 means the images are pixel-identical. That inverted scale is the one thing people get wrong with this node, and it's a shame, because GMSD is quietly one of the best cheap metrics you can run - it consistently outperforms SSIM in benchmark after benchmark while being simpler and faster.

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. Most SSIM-style metrics average a local similarity map. GMSD deliberately does the opposite: it computes gradient magnitudes (edges, essentially) for both images, builds a per-pixel gradient-magnitude similarity map, and then takes the standard deviation of that map as the score. The reasoning: two images that match well on average can still have wildly different local quality - a sharp region next to a ruined region averages out to "fine," and that hides real damage. The spread of the similarity map catches exactly that. Small score = consistent, faithful reproduction. Big score = something is locally broken even if the average looks okay.

Inputs a beginner actually sets:

  • image_a / image_b - candidate vs. reference; image_b is ground truth.
  • data_range - 1.0, ComfyUI 0–1 floats.
  • reduction - mean.
  • t - a tiny regularization constant (default 0.0026) that keeps the fraction stable on flat regions. Leave it.

The gmsd output is a FLOAT, typically small - 0.0 to ~0.3 for sane comparisons, lower 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

Dependency list is a single line (piq>=0.8.0), Python 3.12+, repo archived but stable.

The honest take. This is the traditional metric I'd actually reach for when I want one fast number: it's cheaper than SSIM, more discriminating, and the deviation trick genuinely catches the "looks fine on average, broken in the corner" failure mode that averaging metrics hide. Watch the sign convention and you're set. Pair it with a learned metric when taste matters, but for "did this pipeline hold the edges together," GMSD is the sleeper hit of the whole pack.

Categorypiq

Inputs (5)

NameTypeDefaultDescription
image_aIMAGEInput image
image_bIMAGEReference image
data_rangeFLOAT1.00Maximum value range of images
reductionCOMBOReduction method
tFLOAT0.00Regularization constant

Outputs (1)

NameTypeDescription
gmsdFLOATGradient Magnitude Similarity Deviation