LPIPS
The metric that finally agrees with your eyes
- image_a
- image_b
- lpips
If you've ever compared two generations and thought "SSIM says they're basically equal but one clearly looks better," this is the node that fixes your life. LPIPS (Learned Perceptual Image Patch Similarity) replaces hand-designed math with a neural network's internal features: it runs both images through a VGG network and measures the distance between their feature maps at several layers. Features near the input catch texture and edges; features deeper in catch shape and content. Squeeze both into one distance and you get a number that tracks what humans actually think. Lower is better - 0.0 is identical, and smaller means "more perceptually similar." It's the de facto standard for "does this look right?" in the research world, and for good reason.
It's one of the seventeen nodes in comfyui-piq, Laurent Fainsin's wrapper around the piq library.
How it works. The heavy lifting is a VGG16 pretrained on ImageNet, used as a frozen feature extractor. Both images pass through, and at each of several layers the feature maps are compared with a distance (mse or mae), then those per-layer distances are weighted and pooled (reduction - mean gives you one score per image). The replace_pooling flag swaps the VGG max-pooling for average pooling, which changes the features slightly - leave it off unless you know you want it.
The one real gotcha: it downloads weights on first run. LPIPS pulls a pretrained model from the piq project's GitHub releases (lpips_weights.pt) via torch.hub, and it caches it in ~/.cache/torch. First run needs internet; if the node errors with a download/network message, that's what's happening - run once, let it fetch, and it's instant after that. (If the VGG weights themselves aren't cached yet, torchvision pulls those from pytorch.org on the same first run.)
Inputs a beginner actually sets:
image_a/image_b- candidate vs. reference;image_bis ground truth.distance-mse(default) vs.mae; either is fine, pick one and stay consistent when comparing runs.reduction-meanfor a single comparable number.
The lpips output is a FLOAT, typically in the 0.0–0.5 range for real comparisons, lower 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 is a single line: piq>=0.8.0. Python 3.12+. The repo is archived but functional.
The honest take. LPIPS is the one from this pack I'd actually put in a daily workflow - the difference between it and every classical metric here is the difference between "the math checks out" and "it looks right." Run it on GPU if you have one; VGG forward passes on CPU are fine for a few comparisons and sluggish for hundreds. Don't expect it to be a strict ranking of aesthetics - it measures similarity to a reference, not beauty - but for "did my refiner/upscaler actually help," it's the closest thing to a second opinion from your own eyes.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| image_a | IMAGE | Input image | |
| image_b | IMAGE | Reference image | |
| replace_pooling | BOOLEAN | false | Replace max pooling with average pooling |
| distance | COMBO | Distance metric | |
| reduction | COMBO | Reduction method |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| lpips | FLOAT | Learned Perceptual Image Patch Similarity |