• Stars
    star
    400
  • Rank 107,843 (Top 3 %)
  • Language
    Python
  • License
    MIT License
  • Created about 4 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

PyTorch Image Quality Assessement package

PyTorch Image Quality Assessment

PIQA is a collection of PyTorch metrics for image quality assessment in various image processing tasks such as generation, denoising, super-resolution, interpolation, etc. It focuses on the efficiency, conciseness and understandability of its (sub-)modules, such that anyone can easily reuse and/or adapt them to its needs.

PIQA should be pronounced pika (like Pikachu ⚡️)

Installation

The piqa package is available on PyPI, which means it is installable via pip.

pip install piqa

Alternatively, if you need the latest features, you can install it from the repository.

pip install git+https://github.com/francois-rozet/piqa

Getting started

In piqa, each metric is associated to a class, child of torch.nn.Module, which has to be instantiated to evaluate the metric. All metrics are differentiable and support CPU and GPU (CUDA).

import torch
import piqa

# PSNR
x = torch.rand(5, 3, 256, 256)
y = torch.rand(5, 3, 256, 256)

psnr = piqa.PSNR()
l = psnr(x, y)

# SSIM
x = torch.rand(5, 3, 256, 256, requires_grad=True).cuda()
y = torch.rand(5, 3, 256, 256).cuda()

ssim = piqa.SSIM().cuda()
l = 1 - ssim(x, y)
l.backward()

Like torch.nn built-in components, these classes are based on functional definitions of the metrics, which are less user-friendly, but more versatile.

from piqa.ssim import ssim
from piqa.utils.functional import gaussian_kernel

kernel = gaussian_kernel(11, sigma=1.5).expand(3, 11, 11)

l = 1 - ssim(x, y, kernel=kernel)

For more information, check out the documentation at piqa.readthedocs.io.

Available metrics

Class Range Objective Year Metric
TV [0, ∞] / 1937 Total Variation
PSNR [0, ∞] max / Peak Signal-to-Noise Ratio
SSIM [0, 1] max 2004 Structural Similarity
MS_SSIM [0, 1] max 2004 Multi-Scale Structural Similarity
LPIPS [0, ∞] min 2018 Learned Perceptual Image Patch Similarity
GMSD [0, ∞] min 2013 Gradient Magnitude Similarity Deviation
MS_GMSD [0, ∞] min 2017 Multi-Scale Gradient Magnitude Similarity Deviation
MDSI [0, ∞] min 2016 Mean Deviation Similarity Index
HaarPSI [0, 1] max 2018 Haar Perceptual Similarity Index
VSI [0, 1] max 2014 Visual Saliency-based Index
FSIM [0, 1] max 2011 Feature Similarity
FID [0, ∞] min 2017 Fréchet Inception Distance

Tracing

All metrics of piqa support PyTorch's tracing, which optimizes their execution, especially on GPU.

ssim = piqa.SSIM().cuda()
ssim_traced = torch.jit.trace(ssim, (x, y))

l = 1 - ssim_traced(x, y)  # should be faster ¯\_(ツ)_/¯

Assert

PIQA uses type assertions to raise meaningful messages when a metric doesn't receive an input of the expected type. This feature eases a lot early prototyping and debugging, but it might hurt a little the performances. If you need the absolute best performances, the assertions can be disabled with the Python flag -O. For example,

python -O your_awesome_code_using_piqa.py

Alternatively, you can disable PIQA's type assertions within your code with

piqa.utils.set_debug(False)

Contributing

If you have a question, an issue or would like to contribute, please read our contributing guidelines.

More Repositories

1

zuko

Normalizing flows in PyTorch
Python
146
star
2

sleek-template

Sleek Template for quick, easy and beautiful LaTeX documents
TeX
140
star
3

lampe

Likelihood-free AMortized Posterior Estimation with PyTorch
Python
72
star
4

torchist

NumPy-style histograms in PyTorch
Python
51
star
5

sda

Official implementation of Score-based Data Assimilation
Python
37
star
6

inox

Stainless neural networks in JAX
Python
30
star
7

postr

A minimal poster template in Typst.
Typst
19
star
8

papers-101

Implementation of papers in 101 lines of code.
Python
18
star
9

dawgz

Unleash the true power of scheduling
Python
17
star
10

diffusion-priors

Learning Diffusion Priors from Observations by Expectation Maximization
Python
17
star
11

adopptrs

Automatic Detection Of Photovoltaic Panels Through Remote Sensing
Python
16
star
12

sleek-beamer

LaTeX sleek beamer template
TeX
9
star
13

sudoku

Sudoku grid and digits detection
Python
4
star
14

vsop-compiler

Implementation of a VSOP compiler
C++
4
star
15

uci-datasets

UCI datasets from the MAF paper
Python
3
star
16

sleek-poster

LaTeX sleek poster template
TeX
2
star
17

elen0060-2

Projects of information and coding theory
Python
2
star
18

info2049-1

Sentiment analysis using deep learning methods.
Python
2
star
19

amnre

Arbitrary Marginal Neural Ratio Estimation for Likelihood-free Inference
Python
2
star
20

benchmark_error

Python
1
star
21

info0054-1

Projet de programmation fonctionnelle
Scheme
1
star
22

proj0001-1

Projet d'application de méthodes numériques
MATLAB
1
star
23

elen0016-2

Computer vision project
Python
1
star
24

whitespacy

Polyglot formatter for C and Whitespace
Python
1
star
25

info8003-1

Assignments of Reinforcement Learning
Python
1
star
26

math0462-1

Project of discrete optimization
Julia
1
star
27

math0488-1

Projet d'étude de processus stochastiques
MATLAB
1
star
28

syst0002-2

Projet d'analyse de systèmes
MATLAB
1
star