ComfyUI Node

HaarPSI

A perceptual metric that's fast enough to run everywhere

By Laurent2916·Created about a year ago·Updated about a year ago· 0
HaarPSI
  • image_a
  • image_b
  • scales
  • haar_psi
data_range1.00
subsampletrue
c30.00
alpha4.20
reduction

HaarPSI (Haar Perceptual Similarity Index) is the metric that says "perceptual similarity doesn't need a neural network." It runs the image through a Haar wavelet decomposition - the cheapest wavelet there is - and scores local similarity on the wavelet coefficients, weighted by how much signal each location actually carries. The result is a genuinely perceptual-ish score (higher better, 1.0 identical) that costs a fraction of a learned model and beats most of the classical field on correlation with human opinion.

It's one of the seventeen nodes in comfyui-piq, Laurent Fainsin's wrapper around the piq library. Standard pack shape: image_a/image_b in, one FLOAT out, "piq" category, no downloads.

How it works. A Haar wavelet transform decomposes each image into low-frequency approximation and high-frequency detail coefficients at multiple scales (the scales input, default 3 - with subsample on, which is the standard). The high-frequency coefficients catch edges and texture; the low-frequency ones carry the coarse structure. Local similarities are computed on the coefficients and fused with a weighting derived from the coefficient magnitudes themselves - strong responses, which are the parts your visual system actually attends to, count more. The c (stability, default 30) and alpha (weighting, default 4.2) constants are from the paper. The whole thing is wavelet math on small kernels, so it's fast.

Inputs a beginner actually sets:

  • image_a / image_b - candidate vs. reference; image_b is ground truth.
  • data_range - 1.0 for ComfyUI's 0–1 floats.
  • reduction - mean.
  • scales, subsample, c, alpha - leave at defaults; these are tuned to the original validation.

The haar_psi output is a FLOAT in [0, 1], higher 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

Single dependency (piq>=0.8.0), Python 3.12+, repo archived but stable.

The honest take. If you want the most perceptual signal per millisecond from the traditional half of this pack, HaarPSI is a strong candidate. It's the kind of node you can drop into a batch-evaluation workflow without noticing the cost - run it over an entire grid of seeds and sort by score. It won't have the taste of a learned metric like LPIPS, but it also won't need a ~500 MB model download or a GPU to keep up. For "sort these 200 candidates," it's quietly ideal.

Categorypiq

Inputs (8)

NameTypeDefaultDescription
image_aIMAGEInput image
image_bIMAGEReference image
data_rangeFLOAT1.00Maximum value range of images
scalesINTEGER3Number of wavelet scales
subsampleBOOLEANtrueWhether to perform subsampling
cFLOAT30.00Stability constant
alphaFLOAT4.20Weighting factor
reductionCOMBOReduction method

Outputs (1)

NameTypeDescription
haar_psiFLOATHaar Perceptual Similarity Index