Skip to content
Back to skills

Lpips Feature Distance

ASecurity

Compute LPIPS-style perceptual patch distances from normalized multi-layer feature differences with optional non-negative calibration weights.

  • 247 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 9, 2026
testingpythonbash

Security analysis

A100/100

Scanned September 9, 2026

npx -y skills add VectorSpaceLab/AREX-Skill --skill lpips_feature_distance --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Lpips Feature Distance?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Lpips Feature Distance
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vectorspacelab-lpips-feature-distance/badge)](https://www.skillsdirectory.com/skills/vectorspacelab-lpips-feature-distance)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

SKILL.md
---
name: lpips_feature_distance
description: Compute LPIPS-style perceptual patch distances from normalized multi-layer feature differences with optional non-negative calibration weights.
---

# LPIPS Feature Distance

Use this skill when you need a lightweight, auditable implementation of the LPIPS distance mechanism from Zhang et al. 2018, especially for bounded recovery experiments where full pretrained networks may be unavailable.

Do not use it to claim full official LPIPS reproduction unless the feature extractor and learned weights are the real pretrained LPIPS assets. A deterministic proxy extractor must be labeled as proxy.

## Inputs

- Two RGB images or batches as Python lists with shape `N x C x H x W`, `C x H x W`, or `H x W x C`.
- Input range: `minus_one_to_one` or `zero_to_one`.
- Optional non-negative layer weights.
- Optional feature records produced externally; otherwise use the deterministic proxy extractor in `scripts/lpips_distance.py`.

## Outputs

- Scalar distance per image pair.
- Per-layer contribution details for mechanism checks.

## Workflow

1. Normalize image values to the declared `[-1,1]` scale.
2. Build multi-scale proxy features or consume supplied layer features.
3. L2-normalize features across channels per spatial location.
4. Square feature differences for each layer.
5. Apply non-negative calibration weights.
6. Spatially average and sum layer contributions.
7. Record whether the run used proxy or real features.

## Validation

Run:

```bash
python scripts/lpips_distance.py --self-test
python tests/test_lpips_distance.py
```

## Limitations

The bundled script uses standard-library deterministic proxy features. It is mechanism-faithful for reduced recovery but not a replacement for official pretrained AlexNet/VGG/SqueezeNet LPIPS scores.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…