Sign inDemoInstall


Package Overview
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies



PyTorch Toolbox for Image Quality Assessment



PyTorch Toolbox for Image Quality Assessment

An IQA toolbox with pure python and pytorch. Please refer to Awesome-Image-Quality-Assessment for a comprehensive survey of IQA methods and download links for IQA datasets.

google colab logo PyPI visitors Documentation Status Awesome Citation

:open_book: Introduction

This is a image quality assessment toolbox with pure python and pytorch. We provide reimplementation of many mainstream full reference (FR) and no reference (NR) metrics (results are calibrated with official matlab scripts if exist). With GPU acceleration, most of our implementations are much faster than Matlab. Please refer to the following documents for details:

📦 Model Cards | 🗃️ Dataset Cards | 🤗 Datasets | 📚 Documentation

:triangular_flag_on_post: Updates/Changelog

  • Apr 24, 2024. Add inception_score and console entry point with pyiqa command.
  • Mar 11, 2024. Add unique, refer to official repo here. Thanks for the contribution from Weixia Zhang 🤗.
  • :boom: Jan 31, 2024. Add qalign for both NR and IAA. It is our most powerful unified metric based on large vision-language models, and shows remarkable performance and robustness. Refer Q-Align for more details. Use it with the following codes:
    qalign = create_metric('qalign').cuda()
    quality_score = qalign(input, task_='quality')
    aesthetic_score = qalign(input, task_='aesthetic')
  • Jan 19, 2024. Add wadiqam_fr and wadiqam_nr. All implemented methods are usable now 🍻.
  • Dec 23, 2023. Add liqe and liqe_mix. Thanks for the contribution from Weixia Zhang 🤗.
  • Oct 09, 2023. Add datasets: PIQ2023, GFIQA. Add metric topiq_nr-face. We release example results on FFHQ here for reference.
  • More

:zap: Quick Start

Dependencies and Installation

  • Ubuntu >= 18.04
  • Python >= 3.8
  • PyTorch >= 1.12
  • Torchvision >= 0.13
  • CUDA >= 10.2 (if use GPU)
# Install with pip
pip install pyiqa

# Install latest github version
pip uninstall pyiqa # if have older version installed already 
pip install git+

# Install with git clone
git clone
cd IQA-PyTorch
pip install -r requirements.txt
python develop

Basic Usage

Commandline Usage

You can now simply use the package with commandline interface.

# list all available metrics
pyiqa -ls

# test with default settings
pyiqa [metric_name(s)] --target [image_path or dir] --ref [image_path or dir]
Code Usage
import pyiqa
import torch

# list all available metrics

device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")

# create metric with default setting
iqa_metric = pyiqa.create_metric('lpips', device=device)
# Note that gradient propagation is disabled by default. set as_loss=True to enable it as a loss function.
# iqa_loss = pyiqa.create_metric('lpips', device=device, as_loss=True)

# create metric with custom setting
iqa_metric = pyiqa.create_metric('psnr', test_y_channel=True, color_space='ycbcr').to(device)

# check if lower better or higher better

# example for iqa score inference
# Tensor inputs, img_tensor_x/y: (N, 3, H, W), RGB, 0 ~ 1
score_fr = iqa_metric(img_tensor_x, img_tensor_y)

# img path as inputs.
score_fr = iqa_metric('./ResultsCalibra/dist_dir/I03.bmp', './ResultsCalibra/ref_dir/I03.bmp')

# For FID metric, use directory or precomputed statistics as inputs
# refer to clean-fid for more details:
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")
Example Test script

Example test script with input directory/images and reference directory/images.

# example for FR metric with dirs
python -m LPIPS[or lpips] -i ./ResultsCalibra/dist_dir[dist_img] -r ./ResultsCalibra/ref_dir[ref_img]

# example for NR metric with single image
python -m brisque -i ./ResultsCalibra/dist_dir/I03.bmp

:1st_place_medal: Benchmark Performances and Model Zoo

Results Calibration

Please refer to the results calibration to verify the correctness of the python implementations compared with official scripts in matlab or python.

⏬ Download Benchmark Datasets

For convenience, we upload all related datasets to huggingface. Note that we only collect the datasets for academic, research, and educational purposes. It is important for the users to adhere to the usage guidelines, licensing terms, and conditions set forth by the original creators or owners of each dataset. Here are example codes to download datasets from huggingface:

import os
from huggingface_hub import snapshot_download

save_dir = './datasets'
os.makedirs(save_dir, exist_ok=True)

filename = "meta_info.tgz"
snapshot_download("chaofengc/IQA-Toolbox-Datasets", repo_type="dataset", local_dir=save_dir, allow_patterns=filename, local_dir_use_symlinks=False)

os.system(f"tar -xzvf {save_dir}/{filename} -C {save_dir}")

Examples to specific dataset options can be found in ./options/default_dataset_opt.yml. Details of the dataloader inferface and meta information files can be found in Dataset Preparation

Performance Evaluation Protocol

We use official models for evaluation if available. Otherwise, we use the following settings to train and evaluate different models for simplicity and consistency:

Metric TypeTrainTestResults
FRKADID-10kCSIQ, LIVE, TID2008, TID2013FR benchmark results
NRKonIQ-10kLIVEC, KonIQ-10k (official split), TID2013, SPAQNR benchmark results
Aesthetic IQAAVAAVA (official split)IAA benchmark results

Results are calculated with:

  • PLCC without any correction. Although test time value correction is common in IQA papers, we want to use the original value in our benchmark.
  • Full image single input. We do not use multi-patch testing unless necessary.

Basically, we use the largest existing datasets for training, and cross dataset evaluation performance for fair comparison. The following models do not provide official weights, and are retrained by our scripts:

Metric TypeReproduced Models
NRcnniqa, dbcnn, hyperiqa, wadiqam_nr
Aesthetic IQAnima, nima-vgg16-ava

Important Notes:

  • Due to optimized training process, performance of some retrained approaches may be different with original paper.
  • Results of all retrained models by ours are normalized to [0, 1] and change to higher better for convenience.
  • Results of KonIQ-10k, AVA are both tested with official split.
  • NIMA is only applicable to AVA dataset now. We use inception_resnet_v2 for default nima.
  • MUSIQ is not included in the IAA benchmark because we do not have train/split information of the official model.

Benchmark Performance with Provided Script

Here is an example script to get performance benchmark on different datasets:

# NOTE: this script will test ALL specified metrics on ALL specified datasets
# Test default metrics on default datasets
python -m psnr ssim -d csiq tid2013 tid2008

# Test with your own options
python -m psnr --data_opt options/example_benchmark_data_opts.yml

python --metric_opt options/example_benchmark_metric_opts.yml tid2013 tid2008

python --metric_opt options/example_benchmark_metric_opts.yml --data_opt options/example_benchmark_data_opts.yml

:hammer_and_wrench: Train

Example Train Script

Example to train DBCNN on LIVEChallenge dataset

# train for single experiment
python pyiqa/ -opt options/train/DBCNN/train_DBCNN.yml

# train N splits for small datasets
python pyiqa/ -opt options/train/DBCNN/train_DBCNN.yml

:beers: Contribution

Any contributions to this repository are greatly appreciated. Please follow the contribution instructions for contribution guidance.

:scroll: License

This work is licensed under a NTU S-Lab License and Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Creative Commons License

:bookmark_tabs: Citation

If you find our codes helpful to your research, please consider to use the following citation:

  title={{IQA-PyTorch}: PyTorch Toolbox for Image Quality Assessment},
  author={Chaofeng Chen and Jiadi Mo},
  howpublished = "[Online]. Available: \url{}"

Please also consider to cite our works on image quality assessment if it is useful to you:

  title={TOPIQ: A Top-down Approach from Semantics to Distortions for Image Quality Assessment},
  author={Chen, Chaofeng and Mo, Jiadi and Hou, Jingwen and Wu, Haoning and Liao, Liang and Sun, Wenxiu and Yan, Qiong and Lin, Weisi},
  journal={arXiv preprint arXiv:2308.03060},
  title={Q-Align: Teaching LMMs for Visual Scoring via Discrete Text-Defined Levels},
  author={Wu, Haoning and Zhang, Zicheng and Zhang, Weixia and Chen, Chaofeng and Li, Chunyi and Liao, Liang and Wang, Annan and Zhang, Erli and Sun, Wenxiu and Yan, Qiong and Min, Xiongkuo and Zhai, Guangtai and Lin, Weisi},
  journal={arXiv preprint arXiv:2312.17090},
  institution={Nanyang Technological University and Shanghai Jiao Tong University and Sensetime Research},
  note={Equal Contribution by Wu, Haoning and Zhang, Zicheng. Project Lead by Wu, Haoning. Corresponding Authors: Zhai, Guangtai and Lin, Weisi.}

:heart: Acknowledgement

The code architecture is borrowed from BasicSR. Several implementations are taken from: IQA-optimization, Image-Quality-Assessment-Toolbox, piq, piqa, clean-fid

We also thanks the following public repositories: MUSIQ, DBCNN, NIMA, HyperIQA, CNNIQA, WaDIQaM, PieAPP, paq2piq, MANIQA

:e-mail: Contact

If you have any questions, please email



Did you know?


Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.


Related posts

SocketSocket SOC 2 Logo


  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap


Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc