ComfyUI Node

Image MSE

The Image MSE node

By Duanyll·Created about a year ago·Updated 4 months ago· 2
Image MSE
  • image1
  • image2
  • mask
  • mse

Mean Squared Error is the most basic possible "how different are these two images" score, and the Image MSE node gives it to you as a single FLOAT. Feed it a generated image and its reference, and it tells you the average squared difference per pixel, computed in ComfyUI's [0, 1] range. Lower is better; zero means identical.

It's not the metric you'd cite in a paper, but it's the workhorse for quick automated checks - a comparison branch that fails a workflow when MSE climbs past a threshold, a sanity check that an img2img pass didn't wander off, that sort of thing.

How it works

Both images get normalized and clamped to [0, 1], the difference is squared per pixel per channel, and everything is averaged. The one knob it gives you is the optional mask: supply a MASK and only pixels where the mask is 1 count toward the score. That lets you measure, say, just the subject while ignoring the background you don't care about.

Inputs: image1, image2 (required), mask (optional). Output: a single mse FLOAT. The node also displays the value right on the node in the UI, so you can see it without wiring anything.

Caveats

  • The two images must have the same spatial dimensions. Mismatched shapes raise an error - resize first.
  • MSE punishes large errors out of proportion (it's squared), so a few blown-out pixels dominate the score. If that's skewing your judgment, the pack's MAE node (linear, not squared) or SSIM (structural) will tell a fairer story. If you want all of them plus PSNR in one pass, use Image Diff Metrics.

Installing it

It's in Duanyll Nodepack. ComfyUI Manager → search "Duanyll Nodepack" → install, then restart. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/Duanyll/duanyll_nodepack

This node itself only needs numpy, which ComfyUI already ships - no extra dependencies hiding here. It lives under duanyll/metric in the node menu.

Honest take: for one-off eyeballing, you don't need it - you have eyes. MSE nodes earn their keep inside comparison loops and thresholded branches where a number you can gate on beats a feeling.

Categoryduanyll/metric

Inputs (3)

NameTypeDefaultDescription
image1IMAGE
image2IMAGE
maskoptMASK

Outputs (1)

NameTypeDescription
mseFLOAT