ComfyUI Node

DISTS

The deep metric that respects texture

By Laurent2916·Created about a year ago·Updated about a year ago· 0
DISTS
  • image_a
  • image_b
  • dists
reduction

LPIPS is great, but it has a blind spot: it underweights texture. Two images with identical structure but different grain, brushwork, or fabric detail can score deceptively close. DISTS (Deep Image Structure and Texture Similarity) is the fix - it's a learned metric that deliberately splits its feature comparison into a structure term and a texture term, so it actually notices when the "look" of a surface changes. Higher is better here (it's a similarity in [0, 1], 1.0 identical) - which is the opposite direction from LPIPS, and the first thing that trips people up. It's the metric you reach for when you're comparing styles, textures, and materials, not just layout.

It's a node in comfyui-piq, Laurent Fainsin's wrapper around the piq library.

How it works. Both images go through a VGG-style network trained specifically for the DISTS task. At each of several layers the features are split conceptually into two similarity signals: one that compares global statistics (means - this is the "texture" signal, because texture is a property of regions, not exact pixel placement) and one that compares spatially matched features (this is the "structure" signal). The two are weighted and pooled into the final score. Because texture comparison uses pooled statistics rather than strict pixel matching, two images with the same kind of texture but different exact placement still score as similar - which is exactly what you want when comparing brushstrokes or grain.

The one real gotcha, same as LPIPS: it downloads dists_weights.pt from the piq project's GitHub releases on first run and caches it via torch.hub. First run needs internet; after that it's local.

Inputs a beginner actually sets:

  • image_a / image_b - candidate vs. reference; image_b is ground truth.
  • reduction - mean.

That's it. DISTS is the most minimal node in the pack - two images, one reduction choice, done.

The dists 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

Requirements: piq>=0.8.0. Python 3.12+, repo archived but functional.

The honest take. DISTS is the learned metric I'd run next to LPIPS, not instead of it - they disagree in informative ways, and the disagreement is usually "LPIPS thinks it's the same picture, DISTS noticed the texture changed." That makes it excellent for judging whether a LoRA or style transfer actually altered the surface character of an image. It's a touch more compute than LPIPS and gets less community airtime, but it's the one that catches the failure mode everyone else misses.

Categorypiq

Inputs (3)

NameTypeDefaultDescription
image_aIMAGEInput image
image_bIMAGEReference image
reductionCOMBOReduction method

Outputs (1)

NameTypeDescription
distsFLOATDeep Image Structure and Texture Similarity