lpips
LPIPS Similarity metric
What it is and what it does
LPIPS is a learned perceptual similarity metric that measures how different two images are by comparing their deep neural network feature representations. Rather than using pixel-level differences, it leverages the fact that intermediate activations from pre-trained networks (AlexNet, VGG, or SqueezeNet) correlate well with human perceptual judgments. The package provides three network variants with optional linear calibration layers trained on the Berkeley-Adobe Perceptual Patch Similarity (BAPPS) dataset.
You use it by instantiating a loss function object with your chosen network, then calling it on pairs of PyTorch tensors (images normalized to [-1, 1] range). It returns a scalar or batch of distances where lower values mean more similar images. The metric can be used for evaluation (comparing generated images to references) or as a differentiable loss function for optimization tasks like image generation, super-resolution, or deblurring.
Use it for:
- Evaluate image generation quality by measuring perceptual distance between generated and reference images
- Use as a loss function during training of image-to-image translation or super-resolution models
- Compare different image processing algorithms (denoising, deblurring, color correction) against human perception
- Benchmark perceptual quality of compressed or distorted images in computer vision pipelines
- Optimize image synthesis tasks by backpropagating through the metric to guide model training
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Computes perceptual similarity between image pairs using deep neural network features, returning a scalar distance metric where lower values indicate more similar images.
Yes, if you need a perceptual image similarity metric for computer vision tasks. The package is stable, has low dependencies, and is widely used (1.2M monthly downloads). However, it is dormant—no active maintenance since 2021—so expect no bug fixes or updates. Install it for evaluation or loss functions in image generation, super-resolution, or quality assessment workflows where perceptual alignment matters more than pixel-level similarity.
Install
lpips on PyPI
pip
pip install lpipsuv
uv add lpipspoetry
poetry add lpipsInstalling lpips
Before you install
Low installation friction with a pure Python wheel. The package is dormant (last release August 2021, last commit July 2024) but remains functional; it depends on stable, widely-used libraries (torch, torchvision, numpy, scipy, tqdm).
License in practice
Permissive BSD license allows commercial and private use with minimal restrictions.
Quickstart
pip install lpips
import lpips
import torch
loss_fn = lpips.LPIPS(net='alex')
img0 = torch.zeros(1, 3, 64, 64) # RGB, normalized to [-1, 1]
img1 = torch.zeros(1, 3, 64, 64)
distance = loss_fn(img0, img1)
Requires PyTorch 1.0+ and torchvision; images must be PyTorch tensors with shape (N, 3, H, W) normalized to [-1, 1] range.
Verify before relying
- Whether pre-trained model weights are downloaded automatically on first use or require manual setup
- Memory requirements for different network variants (SqueezeNet, AlexNet, VGG) mentioned in the description
- GPU memory constraints when processing large batches or high-resolution images
Package facts
| License | not declared (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 5 — torch, torchvision, numpy, scipy, tqdm |
| Maintenance | dormant — 1,815 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,205,472/month — #4,224 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: lpips-0.1.4-py3-none-any.whl
Tags
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to…
permissive · top 100 on PyPI
huggingface-hubClient library and CLI tool for downloading,…
permissive · top 100 on PyPI
langchainLangChain provides a framework for building…
permissive · top 1,000 on PyPI
hf-xethf-xet provides chunk-based deduplication and…
permissive · top 1,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
transformersTransformers provides a unified framework for…
permissive · top 1,000 on PyPI
pixelhogCompares PNG screenshots pixel-by-pixel and…
permissive · top 5,000 on PyPI
image-similarity-measuresComputes eight standard image similarity…
permissive · top 15,000 on PyPI
pytorch-metric-learningProvides metric learning loss functions,…
permissive · top 5,000 on PyPI
pyiqaPyIQA provides a PyTorch-based toolbox for…
noncommercial · top 15,000 on PyPI
imagededupFinds exact and near-duplicate images in…
permissive · top 15,000 on PyPI
piqPIQ provides a collection of image quality…
permissive · top 15,000 on PyPI
pytorch-fidComputes Fréchet Inception Distance (FID), a…
permissive · top 15,000 on PyPI
clip-benchmarkEvaluates CLIP-like vision-language models on…
permissive · top 15,000 on PyPI
pytorch-msssimComputes fast, differentiable SSIM and MS-SSIM…
permissive · top 15,000 on PyPI
ImageHashImageHash computes perceptual fingerprints of…
permissive · top 5,000 on PyPI