Image Diff Metrics
All four image-diff metrics in one node — MSE, MAE, PSNR, SSIM with a mask
- image1
- image2
- mask
- mse
- mae
- psnr_db
- ssim
- details
Image Diff Metrics is the all-in-one version of the pack's single-metric nodes: one node, both images in, and you get MSE, MAE, PSNR, and SSIM out of the same run - plus a details string that spells all four out for the node's UI. If you're building any kind of evaluation or comparison pipeline - "did this upscale actually hold detail," "does this model's output match the reference," regression-testing a sampler change - this is the one you want over the singles, because all four metrics agree on the same masked region and the same batch handling.
How it works
The four metrics share one code path, which is the right way to think about them:
- MSE (mean squared error) - the average of squared pixel differences, computed in the
[0, 1]range. Lower is better. Punishes big errors hard. - MAE (mean absolute error) - the average of absolute differences. Lower is better. More forgiving of a few bad pixels than MSE.
- PSNR (peak signal-to-noise ratio, dB) - derived straight from the MSE:
-10 * log10(mse). Higher is better. Returns+infwhen the images are identical, which is correct but trips people up if they try to average it. - SSIM (structural similarity) - the perceptually-minded one, using Gaussian-weighted windows from scikit-image, averaged across RGB channels. Range is roughly
[-1, 1], higher is better. This is the one that actually agrees with your eyes on "structure preserved vs. smeared."
The optional mask restricts all four to a region - pixels where the mask is 1 count, everything else is ignored. That's the killer feature for evaluation workflows: compare the face area, or the background, or whatever region you actually care about, instead of letting a busy background dominate the score.
Inputs and outputs
image1,image2- the pair to compare. They must have matching spatial dimensions; the node raises a clear error if not, so resize first.mask(optional) - a MASK restricting the metric to a region.
Outputs: mse, mae, psnr_db, ssim (all FLOAT), and details (STRING). The numbers wire into logic nodes for automated comparison; the details string is just for reading.
Installing it
It's part of Duanyll Nodepack - ComfyUI Manager, search "Duanyll Nodepack", install, restart. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/Duanyll/duanyll_nodepack
Here's the gotcha to file away: the SSIM half needs scikit-image, and it's not in the pack's requirements. The import is lazy - it only happens when you actually run a node that computes SSIM - so the pack installs fine and then throws ModuleNotFoundError mid-run the first time you hit this node. Fix it with pip install scikit-image in your ComfyUI environment. The rest of the dependencies (numpy, opencv) are standard.
Other than that one dependency, this is a genuinely handy node. If you only need one metric, the singles are there too, but the four-in-one plus mask is the one I reach for.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| image1 | IMAGE | — | |
| image2 | IMAGE | — | |
| maskopt | MASK | — |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| mse | FLOAT | — |
| mae | FLOAT | — |
| psnr_db | FLOAT | — |
| ssim | FLOAT | — |
| details | STRING | — |