pyiqa is a comprehensive PyTorch-based toolbox for Image Quality Assessment (IQA), offering reimplementations of numerous mainstream full-reference (FR) and no-reference (NR) metrics. It aims for GPU acceleration, often outperforming MATLAB counterparts, and provides calibrated results against official scripts where available. The library is actively maintained with frequent releases, adding new metrics, features, and bug fixes.
pip install pyiqaVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to list available metrics, create both Full-Reference (FR) and No-Reference (NR) IQA models, perform inference with dummy PyTorch tensors, and use a metric (like LPIPS) as a loss function with gradient propagation.
Upgrade to v0.1.13 or newer. For users in mainland China, set `export HF_ENDPOINT=https://hf-mirror.com` for faster downloads.
Consult `Model Cards` documentation for specific metrics or test for `backward()` compatibility.
Be aware of potential minor result variations when comparing outputs across v0.1.12 and earlier versions. Ensure consistent evaluation protocols for reproducibility.
Upgrade to `v0.1.14.1` or newer, where this bug has been resolved.
Provide a path to a directory containing images for both target and reference inputs, or use precomputed statistics, when calculating FID. Refer to `clean-fid` documentation for more details.
Upgrade to `v0.1.6.beta` or newer to ensure correct NRQM and PI metric calculations. Recalculate any results obtained with affected older versions.
pip install pyiqa
Downgrade your PyTorch version to one that supports `rfft` (e.g., PyTorch < 1.8) or update `pyiqa` to a version compatible with your PyTorch installation. Check the `pyiqa` GitHub issues or documentation for specific PyTorch version requirements.
Reduce the batch size, decrease the input image resolution, free up GPU memory by deleting unused tensors and calling `torch.cuda.empty_cache()`, or use a GPU with more memory.
Normalize your input image tensor to the [0, 1] range (e.g., `img_tensor = img_tensor / 255.0`) or explicitly set `data_range=255.0` when creating the metric: `iqa_metric = pyiqa.create_metric('lpips', data_range=255.0)`.Install the missing dependency separately using `pip install lpips` or install `pyiqa` with all optional dependencies using `pip install pyiqa[all]`.