cutcutcodec.core.analysis.video.quality.lpips

cutcutcodec.core.analysis.video.quality.lpips(ref: Tensor, dis: Tensor, *args, **kwargs) Tensor[source]

Compute the Learned Perceptual Image Patch Similarity.

It uses the module pip install lpips in backend, based on torch.

Parameters

ref, disarraylike

The 2 images to be compared, of shape ([*batch], height, width, channels). The frames are assumed to be in RGB in range [0, 1]. Gamut and EOTF must be standard rgb.

netstr, default=”alex”

The neuronal network used, “alex” or “vgg”.

threadsint, optional

Defines the number of threads. The value -1 means that the function uses as many calculation threads as there are cores. The default value (0) allows the same behavior as (-1) if the function is called in the main thread, otherwise (1) to avoid nested threads. Any other positive value corresponds to the number of threads used.

Returns

lpipsarraylike

The learned perceptual image patch similarity of each layers.

Examples

>>> import numpy as np
>>> from cutcutcodec.core.analysis.video.quality import lpips
>>> np.random.seed(0)
>>> ref = np.random.random((720, 1080, 3))  # It could also be a torch array list...
>>> dis = 0.8 * ref + 0.2 * np.random.random((720, 1080, 3))
>>> lpips(ref, dis).round(1)
np.float64(0.0)
>>>