Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

PyTorch Image Quality Assessement package

License

NotificationsYou must be signed in to change notification settings

francois-rozet/piqa

Repository files navigation

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 pronouncedpika (like Pikachu ⚡️)

Installation

Thepiqa package is available onPyPI, which means it is installable viapip.

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

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

importtorchimportpiqa# PSNRx=torch.rand(5,3,256,256)y=torch.rand(5,3,256,256)psnr=piqa.PSNR()l=psnr(x,y)# SSIMx=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()

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

frompiqa.ssimimportssimfrompiqa.utils.functionalimportgaussian_kernelkernel=gaussian_kernel(11,sigma=1.5).repeat(3,1,1)ss,cs=ssim(x,y,kernel=kernel)

For more information, check out the documentation atpiqa.readthedocs.io.

Available metrics

ClassRangeObjectiveYearMetric
TV[0, ∞]/1937Total Variation
PSNR[0, ∞]max/Peak Signal-to-Noise Ratio
SSIM[0, 1]max2004Structural Similarity
MS_SSIM[0, 1]max2004Multi-Scale Structural Similarity
LPIPS[0, ∞]min2018Learned Perceptual Image Patch Similarity
GMSD[0, ∞]min2013Gradient Magnitude Similarity Deviation
MS_GMSD[0, ∞]min2017Multi-Scale Gradient Magnitude Similarity Deviation
MDSI[0, ∞]min2016Mean Deviation Similarity Index
HaarPSI[0, 1]max2018Haar Perceptual Similarity Index
VSI[0, 1]max2014Visual Saliency-based Index
FSIM[0, 1]max2011Feature Similarity
FID[0, ∞]min2017Fréchet Inception Distance

Tracing

All metrics ofpiqa supportPyTorch'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 ourcontributing guidelines.


[8]ページ先頭

©2009-2025 Movatter.jp