Library / SDK
chaofengc/IQA-PyTorch avatar
chaofengc/IQA-PyTorch

IQA-PyTorch (pyiqa): a PyTorch toolbox for full-reference and no-reference image quality metrics

🔎 🖼️ 🔥PyTorch Toolbox for Image Quality Assessment, including PSNR, SSIM, LPIPS, FID, NIQE, NRQM(Ma), MUSIQ, TOPIQ, NIMA, DBCNN, BRISQUE, PI and more...

3,456 stars262 forksPythonNOASSERTION

At a glance

What is it?
IQA-PyTorch packages PSNR, SSIM, LPIPS, FID, NIQE, MUSIQ, TOPIQ, NIMA, DBCNN, BRISQUE and others behind one pyiqa.create_metric call. It is convenient for research pipelines, but the licence is noncommercial and the package is self-described as alpha.
Who is it for?
Adopt IQA-PyTorch when you need to compare many full-reference or no-reference metrics on the same tensors without reimplementing each paper, and when a noncommercial licence fits your project. Do not adopt it if you need a commercial redistribution licence, or if you expect a stable API: pyproject.toml classifies the package as Development Status 3 - Alpha.
Can I use it commercially?
Check first. The repository uses a licence we do not classify automatically, so read its LICENSE file before any commercial use.
Is it still maintained?
Yes. The repository last received commits 2 days ago.
What is it written in?
Mainly Python, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 24, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • chaofengc/IQA-PyTorch3,456 ★ · +59
Star history
Repository2026-09-242026-11-24
chaofengc/IQA-PyTorch3.4k3.5k

59 Stars in the last 61 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

The gap IQA-PyTorch fills between papers and a working metric call

Image quality assessment papers rarely ship reusable code. Each metric has its own input convention, its own normalization, and often a MATLAB reference implementation that defines the expected numbers. IQA-PyTorch collects full-reference metrics such as PSNR, SSIM, MS-SSIM, LPIPS, DMM and FID alongside no-reference metrics such as NIQE, NRQM(Ma), MUSIQ, TOPIQ, NIMA, DBCNN, BRISQUE, PI, CLIP-IQA and QualiCLIP, and exposes them through one Python entry point. The README states that the reimplementations are calibrated against official MATLAB scripts when those exist, and that GPU acceleration makes them faster than the MATLAB counterparts. That calibration claim is the part worth caring about: a metric that returns a plausible-looking number but drifts from the reference implementation is worse than no metric, because it silently invalidates comparisons across papers. The audience is researchers and engineers who need to score generated or restored images, train a model with a perceptual loss, or reproduce a benchmark, and who would rather not vendor a dozen separate repositories. Recent changelog entries show the toolbox tracks new work: qrealign on a Qwen3.5-VL backbone in June 2026, fgresq in May 2026, dmm and maclip in December 2025, afine in September 2025.

How pyiqa.create_metric dispatches to the right architecture

The design is a registry plus a factory. pyiqa.list_models() enumerates the available metric names, and pyiqa.create_metric(name, device=..., as_loss=...) returns an object you call like a function. The metric object carries a lower_better flag, which matters because SSIM and LPIPS disagree about direction: the README example wraps SSIM as 1 - ssim_loss(...) precisely because SSIM is not lower-better. Inputs are flexible. Full-reference metrics accept either two tensors shaped (N, 3, H, W) in RGB with values from 0 to 1, or two file paths. FID is the outlier: it takes directories or precomputed statistics rather than image pairs, and forwards to clean-fid, with optional dataset_name, dataset_res and dataset_split arguments for the reference statistics. Gradient propagation is disabled by default. Setting as_loss=True turns a metric into a differentiable loss, but the README warns that not all metrics support backpropagation and points to the Model Cards document; using a non-differentiable metric as a loss will fail or silently produce no gradient. Weights and dataset configurations live in the pyiqa package, with default_dataset_configs.yml shipped as package data, and the model cache defaults to ~/.cache/torch/hub/pyiqa/.

Installing pyiqa and scoring a first image pair

The README gives four installation routes. The plain pip route is the shortest; the uv route is offered as a faster alternative; the git+https route pulls the latest repository state; and the clone plus editable install is for people who want to modify the code. If you have an older pyiqa installed, the README says to uninstall it first before installing from git.

bash
pip install pyiqa

After installation the package adds a pyiqa console script, declared in pyproject.toml as pyiqa.pyiqa_cmd:main. Running it with -ls lists every metric the toolbox knows about, which is the fastest way to confirm the install worked.

bash
pyiqa -ls

For a real scoring run from the command line, pass one or more metric names, a test path with -t and a reference path with -r, plus a device. The README shows the general form with --verbose for per-image output.

bash
pyiqa [metric_name(s)] -t [image_path or dir] -r [image_path or dir] --device [cuda or cpu] --verbose

In Python, the same workflow starts with create_metric. The README example creates LPIPS on the available device and reads lower_better to know which direction is better.

python
import pyiqa
import torch

device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")
iqa_metric = pyiqa.create_metric('lpips', device=device)
print(iqa_metric.lower_better)
score_fr = iqa_metric('./ResultsCalibra/dist_dir/I03.bmp', './ResultsCalibra/ref_dir/I03.bmp')

For FID the call shape changes: pass directories instead of file pairs, or let the metric fetch reference statistics by dataset name.

python
fid_metric = pyiqa.create_metric('fid')
score = fid_metric('./ResultsCalibra/dist_dir/', './ResultsCalibra/ref_dir')
score = fid_metric('./ResultsCalibra/dist_dir/', dataset_name="FFHQ", dataset_res=1024, dataset_split="trainval70k")

Two operational notes from the README. First, the default model cache directory is ~/.cache/torch/hub/pyiqa/, so the first call for a learned metric downloads weights there. Second, if Hugging Face is unreachable, the README suggests the mirror hf-mirror.com and setting HF_ENDPOINT, which matters because both weights and datasets are hosted there.

The noncommercial licence and the alpha classifier are the two real constraints

Most toolboxes in this space are permissively licensed, and IQA-PyTorch is not. pyproject.toml declares license = "PolyForm-Noncommercial-1.0.0" and ships two licence files, LICENSE and LICENSE-S-Lab. PolyForm Noncommercial restricts use to noncommercial purposes, which rules out shipping pyiqa inside a commercial product or a paid service without a separate arrangement. The repository's own metadata is the source here; the README does not discuss licensing terms or how to obtain a commercial licence, so if that is your situation, nothing in the repository files states what that path is. Separately, the classifiers list Development Status :: 3 - Alpha. That is the project's own label. It does not mean the metrics are wrong, but it does mean the Python API can move between releases: the changelog shows metrics being added at a steady pace, and the requirements file carries a note that transformers>=5.0 is needed for qrealign while the rest of the toolbox is verified on 5.x, with qrealign needing 5.2 for native qwen3_5 and running on 5.0 or 5.1 through a vendored shim. Dependency coupling like that is a maintenance surface you inherit.

Where IQA-PyTorch is the wrong tool

Three cases stand out. If you only need PSNR and SSIM, the dependency tree is disproportionate: requirements.txt pulls in torch, torchvision, timm, transformers, accelerate, bitsandbytes on non-Darwin platforms, facexlib, openai-clip, datasets, scikit-image and more. A twenty-line SSIM implementation has no such footprint. Second, if you need a commercial licence, the PolyForm-Noncommercial-1.0.0 terms are a blocker rather than a detail, and nothing in the repository files describes an alternative grant. Third, if your metric must be differentiable, verify before you build a training loop around it: the README states plainly that gradient propagation is disabled by default and that not all metrics support backpropagation, deferring to the Model Cards document. A metric that scores well but yields no gradient is a debugging session, not a loss function. There is also a subtler failure mode for FID. Because it accepts directories, it is easy to point it at folders with different image counts or preprocessing than the dataset it was calibrated on, and the README's own example passes dataset_name, dataset_res and dataset_split to pin those reference statistics. Skipping those arguments means you are comparing against whatever default the clean-fid path chooses, and the README does not document what that default is.

How it compares with clean-fid and the original metric repositories

The closest single-purpose alternative named in the README is clean-fid, which IQA-PyTorch uses for its FID implementation. clean-fid exists because FID numbers are notoriously sensitive to resizing and quantization: it defines a specific preprocessing pipeline so that reported scores are comparable across papers. If FID is the only metric you need, going to clean-fid directly removes the whole torch, timm and transformers dependency chain and gives you the reference implementation rather than a wrapper around it. The trade-off is scope. clean-fid does FID and nothing else, while IQA-PyTorch gives you FID plus PSNR, SSIM, LPIPS, NIQE, MUSIQ, TOPIQ, NIMA, DBCNN, BRISQUE and the rest under one create_metric call, with a shared device argument and a shared lower_better convention. The other alternative pattern is vendoring each metric's official repository, which is what many research groups do. That gets you the authors' own code and, often, their own licence, at the cost of maintaining a dozen environments and reconciling input conventions yourself. IQA-PyTorch's pitch is that reconciliation work, and the MATLAB calibration claim is what makes it credible rather than just convenient.

Upgrading, testing and what the release history implies

The last push to the default branch was on 2026-08-31, and the most recent release is v0.1.16 from 2026-07-08, following v0.1.15 in March 2026 and a hotfix release v0.1.14.1 in June 2025. Versioning is handled by setuptools-scm with version_scheme = "post-release" and write_to = "pyiqa/version.py", so the version is derived from git tags rather than hand-edited, which is a good sign for reproducibility of installed builds. The Makefile exposes the project's own test targets, and they are worth knowing before you upgrade, because they map to the failure modes above. test_cal runs pytest tests/ -m calibration -v, which is the calibration suite against reference values. test_forward checks that metrics run. test_cs checks CPU and GPU consistency, which matters if you score on CPU in CI and on GPU in production. test_grad checks gradient backward, which is the check to run if you intend to use a metric as a loss. test_dataset and test_fr_dataset check dataset loading for the no-reference and full-reference paths respectively. Running make test covers forward and calibration; make test_all adds the consistency, gradient and dataset suites. On a version bump, the calibration suite is the one that tells you whether a metric's numbers moved.

Editorial conclusion

Adopt IQA-PyTorch when you need to compare many full-reference or no-reference metrics on the same tensors without reimplementing each paper, and when a noncommercial licence fits your project. Do not adopt it if you need a commercial redistribution licence, or if you expect a stable API: pyproject.toml classifies the package as Development Status 3 - Alpha. Before committing, check the Model Cards page for whether your chosen metric supports backpropagation through as_loss=True, and confirm which weights the metric downloads on first use, since the default cache directory is ~/.cache/torch/hub/pyiqa/.

Frequently asked questions

What does IQA stand for in the context of image quality?

Image quality assessment. In IQA-PyTorch it covers both full-reference metrics such as PSNR, SSIM, LPIPS and FID, which compare a distorted image against a reference, and no-reference metrics such as NIQE, MUSIQ, TOPIQ, NIMA and BRISQUE, which score a single image.

How do I install IQA-PyTorch?

The README gives pip install pyiqa as the shortest route, with uv pip install pyiqa as a faster variant, pip install git+https://github.com/chaofengc/IQA-PyTorch.git for the latest repository state, and a git clone followed by pip install -e . for editable installs. If an older version is present, uninstall pyiqa first.

Where does IQA-PyTorch store downloaded model weights?

The README states the default model cache directory is ~/.cache/torch/hub/pyiqa/. Weights are hosted on Hugging Face, and the README suggests hf-mirror.com with the HF_ENDPOINT environment variable when Hugging Face is not reachable.

Can I use a pyiqa metric as a loss function during training?

Yes, by passing as_loss=True to pyiqa.create_metric, because gradient propagation is disabled by default. The README warns that not all metrics support backpropagation, points to the Model Cards document, and notes that you must use the metric in a lower_better way, which is why the SSIM example computes 1 - ssim_loss(...).

What licence does IQA-PyTorch use?

pyproject.toml declares license = "PolyForm-Noncommercial-1.0.0" and the repository ships LICENSE and LICENSE-S-Lab files. The README does not describe the terms or how a commercial licence could be obtained.

Official sources

  1. chaofengc/IQA-PyTorch on GitHub
  2. Issues
  3. Project website
  4. README
  5. Releases
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/chaofengc-iqa-pytorch.svg)](https://hysenlabs.com/projects/chaofengc-iqa-pytorch)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/chaofengc-iqa-pytorch.svg)](https://hysenlabs.com/projects/chaofengc-iqa-pytorch)

Was this useful?