Measures and metrics for image2image tasks. PyTorch.

brisque, fid, gan, generative-models, image-metrics, image-quality, image-quality-assessment, image-to-image, iqa, kid, measures, metrics, ms-ssim, mse, psnr, python3, pytorch, ssim, vif
pip install photosynthesis-metrics==0.4.0



License PyPI version Conda version
CI flake-8 style check CI testing codecov
Quality Gate Status Maintainability Rating Reliability Rating

Collection of measures and metrics for image quality assessment.

  • Unified interface, which is easy to use and extend.
  • Written on pure PyTorch with bare minima of additional dependencies.
  • Extensive user input validation. You code will not crash in the middle of the training.
  • Fast (GPU computations available) and reliable.
  • Most metrics can be backpropagated for model optimization.
  • Supports python 3.6-3.8.

Getting started

The first group of metrics takes image or images as input, e.g., PSNR, SSIM, BRISQUE. We have a functional interface, which returns a metric value, and a class interface, which allows us to use any metric as a loss function.

import torch
from piq import ssim, SSIMLoss

prediction = torch.rand(4, 3, 256, 256, requires_grad=True)
target = torch.rand(4, 3, 256, 256)

ssim_index: torch.Tensor = ssim(prediction, target, data_range=1.)

loss = SSIMLoss(data_range=1.)
output: torch.Tensor = loss(prediction, target)

The second group takes a list of image features, e.g., IS, FID, KID. Image features can be extracted by some feature extractor network separately or by using the compute_feats method of a class.
Important note: compute_feats consumes a data loader of a predefined format.

import torch
from import DataLoader
from piq import FID

first_dl, second_dl = DataLoader(), DataLoader()
fid_metric = FID()
first_feats = fid_metric.compute_feats(first_dl)
second_feats = fid_metric.compute_feats(second_dl)
fid: torch.Tensor = fid_metric(first_feats, second_feats)

If you already have image features, use the class interface for score computation:

import torch
from piq import FID

prediction_feats = torch.rand(10000, 1024)
target_feats = torch.rand(10000, 1024)
msid_metric = MSID()
msid: torch.Tensor = msid_metric(prediction_feats, target_feats)

For a full list of examples, see image metrics and feature metrics examples.

Image metrics

  1. Blind/Referenceless Image Spatial Quality Evaluator (BRISQUE)
  2. Content score
  3. Deep Image Structure and Texture Similarity measure (DISTS)
  4. Feature Similarity Index Measure (FSIM)
  5. Gradient Magnitude Similarity Deviation (GMSD)
  6. Haar Wavelet-Based Perceptual Similarity Index (HaarPSI)
  7. Learned Perceptual Image Patch Similarity measure (LPIPS)
  8. Mean Deviation Similarity Index (MDSI)
  9. Multi-Scale Structural Similarity (MS-SSIM)
  10. Multi-Scale Gradient Magnitude Similarity Deviation (MS-GMSD)
  11. Peak Signal-to-Noise Ratio (PSNR)
  12. Perceptual Image-Error Assessment through Pairwise Preference (PieAPP)
  13. Structural Similarity (SSIM)
  14. Style score
  15. Total Variation (TV)
  16. Visual Information Fidelity (VIF)
  17. Visual Saliency-induced Index (VSI)

Feature metrics

  1. Frechet Inception Distance(FID)
  2. Geometry Score (GS)
  3. Inception Score(IS)
  4. Kernel Inception Distance(KID)
  5. Multi-Scale Intrinsic Distance (MSID)


PyTorch Image Quality (former PhotoSynthesis.Metrics) helps you to concentrate on your experiments without the boilerplate code. The library contains a set of measures and metrics that is continually getting extended. For measures/metrics that can be used as loss functions, corresponding PyTorch modules are implemented.


$ pip install piq

$ conda install piq -c photosynthesis-team -c conda-forge -c PyTorch

If you want to use the latest features straight from the master, clone the repo:

$ git clone


See the open issues for a list of proposed features and known issues.



We appreciate all your contributions. If you plan to:

  • contribute back bug-fixes; please do so without any further discussion
  • close one of open issues, please do so if no one has been assigned to it
  • contribute new features, utility functions, or extensions; please first open an issue and discuss the feature with us

Please see the contribution guide for more information.


Sergey Kastryulin - @snk4tr -
Djamil Zakirov - @zakajd -
Denis Prokopenko - @denproc -