← all notes

LPIPS Loss (Learned Perceptual Image Patch Similarity)

concept

A loss function that helps judge how visually similar two images are. It’s premise is to compare two image similarities from features extracted from both.

The process:

  1. Run both images through a pretrained VGG (or CNN)
  2. Extract feature maps from multiple layers of the pretrained model.
  3. Compute weighted distances between corresponding feature maps.
  4. Aggregate into one loss
𝐿
LPIPS
(
π‘₯
,
Μ‚
π‘₯
)
β‰ˆ
βˆ‘
𝑙
𝑀
𝑙
β€–
πœ‘
𝑙
(
π‘₯
)
βˆ’
πœ‘
𝑙
(
Μ‚
π‘₯
)
β€–
2

The main reason this gets used is that pixel-level reconstruction is a hard loss function and counter-productive for what we really want some models to learn. Sometimes, it’s best to learn the features that the model is supposed to contain and reconstruct those accurately enough for a pretrained model to work against.