Image SSIM
The metric that agrees with your eyes, if you can get it installed
- image1
- image2
- mask
- ssim
SSIM - structural similarity - is the metric people reach for when MSE and PSNR have lied to them one too many times. Instead of comparing raw pixel values, it compares local patterns of brightness and texture using Gaussian-weighted windows, which is why its scores actually track what you see. Two images that look nearly identical get a high SSIM even if every pixel is slightly off (pixel metrics would flag that); a genuinely mangled image scores low no matter what the averages say.
The Image SSIM node returns it as a single FLOAT. The scale is roughly [-1, 1], higher is better - 0.98+ means "structurally the same image," and anything below 0.9 is worth actually looking at.
How it works
The implementation uses scikit-image's structural_similarity with gaussian_weights=True, averaged across the RGB channels, computed in the [0, 1] range. The optional mask works the same way as the rest of this pack's metrics: pixels where the mask is 1 count, everything else is ignored, so you can score just the face, or just the background. The SSIM map is computed and then masked before averaging, so it's a proper region-restricted score rather than a hack.
Inputs: image1, image2 (required), mask (optional). Output: a single ssim FLOAT, displayed on the node as well.
The gotcha: scikit-image isn't in the pack's requirements
This is the one node in the pack that will bite you on install. It imports skimage lazily - only when you actually run it - and scikit-image is not in the pack's requirements.txt. So everything installs clean, and then the first time you run an SSIM node you get a ModuleNotFoundError. Fix:
pip install scikit-image
in your ComfyUI Python environment, then restart. Also note SSIM needs a window larger than a few pixels, so tiny images (like 1×1 crops) will error out.
Installing the node
It's in Duanyll Nodepack: ComfyUI Manager → search "Duanyll Nodepack" → install → restart, or:
cd ComfyUI/custom_nodes
git clone https://github.com/Duanyll/duanyll_nodepack
Find it under duanyll/metric.
If you're building an evaluation pipeline, you usually want the pack's Image Diff Metrics node instead - it returns SSIM alongside MSE, MAE, and PSNR from one run, all using the same masking. But for a single "is this still structurally the same image" number, this is the one to reach for.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| image1 | IMAGE | — | |
| image2 | IMAGE | — | |
| maskopt | MASK | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| ssim | FLOAT | — |