Nodes/imgutils/Imgutils Compare (LPIPS)
ComfyUI Node

Imgutils Compare (LPIPS)

When two images 'look the same' — measure it

By xiaden·Created 2 months ago·Updated 2 months ago· 0
Imgutils Compare (LPIPS)
  • image_a
  • image_b
  • label
  • distance

Pixel-perfect comparisons are useless for judging generations. Two images can be byte-for-byte different and look identical to a human, or look wildly different while sharing the same average color. Imgutils Compare (LPIPS) is the fix: it gives you a single number for how perceptually similar two images are, using a real neural network instead of a diff tool.

LPIPS stands for Learned Perceptual Image Patch Similarity, and the name is the whole idea - it's a network trained to rank image differences the way people actually see them, so it punishes "the face changed" more than "there's a tiny bit more grain." This node is a thin wrapper over lpips_difference from the deepghs/imgutils library (that library even uses LPIPS internally for clustering nearly-identical anime character art). You feed it image_a and image_b, and it returns:

  • distance - a FLOAT, lower is more similar
  • label - a human-readable verdict, with cutoffs baked in: under 0.10 it's "exact", under 0.30 "very similar", under 0.45 "similar", under 0.70 "different", under 0.90 "very different", and beyond that "opposite"

So a distance of 0.12 tells you "these are the same picture, basically," while 0.6 tells you something real changed.

What you'd actually use it for

The honest use case is automation. If you're batch-testing prompts, seeds, or LoRA strengths and generating twenty images per configuration, eyeballing them all is the bottleneck. Route pairs through LPIPS and gate on distance - for example, keep only generations that differ from a reference by at least X (you want variety), or reject generations that are near-copies of the input (you want change). Compare against the source image to spot whether an edit pass actually moved anything, or check two upscale methods against each other to see which one "kept" more of the original's look.

Because it's a metric node and not a generative pass, it's instant - no sampling, no seed lottery. That's the thing to like about the whole compare category: it's cheap enough to run on every image in a batch.

Install & gotchas

Same pack, same install as the rest of imgutils:

cd ComfyUI/custom_nodes/
git clone https://github.com/xiaden/comfyui-imgutils.git
cd comfyui-imgutils
pip install -r requirements.txt

This pack is written against ComfyUI's newer V3 backend API, so it needs ComfyUI 0.25.0+; on older installs the nodes don't register. The LPIPS weights download from HuggingFace Hub on first run (cached in ~/.cache/huggingface/hub/), so the first call is slow and offline runs fail.

Two caveats from actually using these things: the absolute numbers shift with image size and content type, so don't treat 0.3 as a universal "similar" line across different subjects - calibrate it on your own batch once. And LPIPS compares whole images, not content in them; two crops of the same character in different poses will score as "different" and that's correct behavior, not a bug.

Categoryimgutils/compare

Inputs (2)

NameTypeDefaultDescription
image_aIMAGEFirst image to compare.
image_bIMAGESecond image for comparison.

Outputs (2)

NameTypeDescription
labelSTRING
distanceFLOAT