Giter Club home page Giter Club logo

iqa-pytorch's Introduction

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, as well as download links for IQA datasets.

๐Ÿ“– Introduction

This is a image quality assessment toolbox with pure python and pytorch. We provide the following features:

  • โœจ Comprehensive. Support many mainstream full reference (FR) and no reference (NR) metrics
  • โœจ Accurate. Results calibration of our implementation with official matlab scripts (if exist).
  • โœจ Flexible. Support training new DNN models with several public IQA datasets
  • โœจ Differentiable. Most methods support pytorch backward
  • โœจ Convenient. Quick inference and benchmark script

Below are details of supported methods and datasets in this project.

Supported methods and datasets:
FR Method Backward
PieAPP โณ
LPIPS โœ…
DISTS โœ…
WaDIQaM โœ…
CKDN1 โœ…
FSIM โœ…
SSIM โœ…
MS-SSIM โœ…
CW-SSIM โœ…
PSNR โœ…
VIF โœ…
GMSD โœ…
NLPD โœ…
VSI โœ…
MAD โœ…
NR Method Backward
MUSIQ โœ…
DBCNN โœ…
PaQ-2-PiQ โณ
HyperIQA โœ…
NIMA โœ…
WaDIQaM โœ…
CNNIQA โœ…
NRQM(Ma) โณ
HOSA โณ
BRISQUE โœ…
NIQE โœ…
Dataset Type
FLIVE(PaQ-2-PiQ) NR
SPAQ NR/mobile
AVA NR/Aesthetic
PIPAL FR
BAPPS FR
PieAPP FR
KADID-10k FR
KonIQ-10k(++) NR
LIVEChallenge NR
LIVEM FR
LIVE FR
TID2013 FR
TID2008 FR
CSIQ FR

[1] This method use distorted image as reference. Please refer to the paper for details.


๐Ÿšฉ Updates/Changelog

  • Feb 2, 2022. Add MUSIQ inference code, and the converted official weights. See Official codes.
  • More

โณ TODO List

  • โฌœ Benchmark with retrained models of DBCNN, NIMA, etc.
  • โฌœ Add pretrained models on different datasets.

โšก Quick Start

Dependencies and Installation

  • Ubuntu >= 18.04
  • Python >= 3.8
  • Pytorch >= 1.8.1
  • CUDA 10.1 (if use GPU)
  • Other required packages in requirements.txt
# Install with pip
pip install pyiqa

# Install latest github version
pip install git+https://github.com/chaofengc/IQA-PyTorch.git

# Install with git clone 
git clone https://github.com/chaofengc/IQA-PyTorch.git
cd IQA-PyTorch
pip install -r requirements.txt
python setup.py develop 

Quick Inference

Test script

Example test script with input directory and reference directory. Single image is also supported for -i and -r options.

# example for FR metric with dirs 
python inference_iqa.py -n LPIPS[or lpips] -i ./ResultsCalibra/dist_dir -r ./ResultsCalibra/ref_dir 

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

Used as functions in your project

import pyiqa 

# list all available metrics
print(pyiqa.list_models())

# create metric with default setting
iqa_metric = pyiqa.create_metric('lpips').to(device)

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

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

Metrics which support backward can be used for optimization, such as image enhancement.

๐Ÿ› ๏ธ Train

Dataset Preparation

  • You only need to unzip downloaded datasets from official website without any extra operation. And then make soft links of these dataset folder under datasets/ folder. Download links are provided in Awesome-Image-Quality-Assessment.
  • We provide common interface to load these datasets with the prepared meta information files and train/val/test split files, which can be downloaded from download_link and extract them to datasets/ folder.

You may also use the following commands:

mkdir datasets && cd datasets 

# make soft links of your dataset
ln -sf your/dataset/path datasetname

# download meta info files and train split files
wget https://github.com/chaofengc/IQA-PyTorch/releases/download/v0.1-weights/data_info_files.tgz
tar -xvf data_info_files.tgz 

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

Example Train Script

Example to train DBCNN on LIVEChallenge dataset

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

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

๐Ÿฅ‡ 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.

Performances of classical metrics

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 benchmark_results.py -m psnr ssim -d csiq tid2013 tid2008 

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

python benchmark_results.py --metric_opt options/example_benchmark_metric_opts.yml tid2013 tid2008

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

Please refer to benchmark results for benchmark results of traditional metrics.

Performances of deep learning models

Small datasets, n-splits validation

Methods CSIQ TID2008 TID2013 LIVE LIVEM LIVEC
DBCNN

Large dataset performance

Methods Dataset Kon10k LIVEC SPAQ AVA Link(pth)

๐Ÿป Contribution

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

๐Ÿงพ License

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

Creative Commons License

โค๏ธ Acknowledgement

The code architecture is borrowed from BasicSR. Several implementations are taken from

We also thanks the following public repositories:

๐Ÿ“ง Contact

If you have any questions, please email [email protected]

iqa-pytorch's People

Contributors

chaofengc avatar jiadimo avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.