ComfyUI Node

Image MAE

The gentler sibling of MSE for measuring image difference

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

Mean Absolute Error is the linear cousin of MSE: instead of squaring each pixel difference, it takes the absolute value and averages. Same idea, different temperament. Image MAE gives you one FLOAT for "how far apart are these two images on average," computed in the [0, 1] range, and because the errors aren't squared, a handful of bad pixels don't get to dominate the score the way they do with MSE.

That makes it the fairer choice when your two images differ in scattered, localized ways - a few pixels shifted, a small region changed - rather than across the whole frame. If you're comparing a crop or an edit against a source and you care about typical error rather than worst error, MAE is the number you want.

How it works

Both images are normalized to [0, 1], the absolute difference is taken per pixel per channel, and everything is averaged. The optional mask restricts the metric to a region: pixels where the mask is 1 are included, everything else is ignored. That's the same masking behavior shared across this pack's metric nodes, so a score computed here agrees with one computed by Image Diff Metrics on the same masked pair.

Inputs: image1, image2 (required), mask (optional). Output: a single mae FLOAT, also displayed on the node itself in the UI.

Caveats

  • The two images must have matching spatial dimensions, or the node raises an error. Resize before comparing.
  • Like all pixel-space metrics, MAE doesn't know anything about structure. Two images can have the same MAE while one looks obviously broken to you, because "average pixel difference" and "does it look right" are only loosely correlated. Use SSIM when perception matters.

Installing it

It ships in Duanyll Nodepack. In ComfyUI Manager, search "Duanyll Nodepack" and install, then restart ComfyUI. Manual route:

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

No special dependencies beyond numpy, which every ComfyUI install already has. The node sits under duanyll/metric.

If you're building an evaluation loop, the practical answer is usually the pack's Image Diff Metrics node - it returns MAE, MSE, PSNR, and SSIM from one run, all masked consistently. This single-metric version is for when you want exactly one number and nothing else.

Categoryduanyll/metric

Inputs (3)

NameTypeDefaultDescription
image1IMAGE
image2IMAGE
maskoptMASK

Outputs (1)

NameTypeDescription
maeFLOAT