Git Product home page Git Product logo

piq's Introduction

https://raw.githubusercontent.com/photosynthesis-team/piq/master/docs/source/_static/piq_logo_main.png

PyTorch Image Quality (PIQ) is not endorsed by Facebook, Inc.;

PyTorch, the PyTorch logo and any related marks are trademarks of Facebook, Inc.

Pypi Version Conda Version CI flake-8 style check CI testing codecov Quality Gate Status

PyTorch Image Quality (PIQ) is a collection of measures and metrics for image quality assessment. PIQ helps you to concentrate on your experiments without the boilerplate code. The library contains a set of measures and metrics that is continually getting extended. For measures/metrics that can be used as loss functions, corresponding PyTorch modules are implemented.

We provide:

  • Unified interface, which is easy to use and extend.
  • Written on pure PyTorch with bare minima of additional dependencies.
  • Extensive user input validation. Your code will not crash in the middle of the training.
  • Fast (GPU computations available) and reliable.
  • Most metrics can be backpropagated for model optimization.
  • Supports python 3.7-3.10.

PIQ was initially named PhotoSynthesis.Metrics.

Installation

PyTorch Image Quality (PIQ) can be installed using pip, conda or git.

If you use pip, you can install it with:

$ pip install piq

If you use conda, you can install it with:

$ conda install piq -c photosynthesis-team -c conda-forge -c PyTorch

If you want to use the latest features straight from the master, clone PIQ repo:

git clone https://github.com/photosynthesis-team/piq.git
cd piq
python setup.py install

Documentation

The full documentation is available at https://piq.readthedocs.io.

Usage Examples

Image-Based metrics

The group of metrics (such as PSNR, SSIM, BRISQUE) takes an image or a pair of images as input to compute a distance between them. We have a functional interface, which returns a metric value, and a class interface, which allows to use any metric as a loss function.

import torch
from piq import ssim, SSIMLoss

x = torch.rand(4, 3, 256, 256, requires_grad=True)
y = torch.rand(4, 3, 256, 256)

ssim_index: torch.Tensor = ssim(x, y, data_range=1.)

loss = SSIMLoss(data_range=1.)
output: torch.Tensor = loss(x, y)
output.backward()

For a full list of examples, see image metrics examples.

Distribution-Based metrics

The group of metrics (such as IS, FID, KID) takes a list of image features to compute the distance between distributions. Image features can be extracted by some feature extractor network separately or by using the compute_feats method of a class.

Note:
compute_feats consumes a data loader of a predefined format.
import torch
from torch.utils.data import DataLoader
from piq import FID

first_dl, second_dl = DataLoader(), DataLoader()
fid_metric = FID()
first_feats = fid_metric.compute_feats(first_dl)
second_feats = fid_metric.compute_feats(second_dl)
fid: torch.Tensor = fid_metric(first_feats, second_feats)

If you already have image features, use the class interface for score computation:

import torch
from piq import FID

x_feats = torch.rand(10000, 1024)
y_feats = torch.rand(10000, 1024)
msid_metric = MSID()
msid: torch.Tensor = msid_metric(x_feats, y_feats)

For a full list of examples, see feature metrics examples.

List of metrics

Full-Reference (FR)

Acronym Year Metric
PSNR - Peak Signal-to-Noise Ratio
SSIM 2003 Structural Similarity
MS-SSIM 2004 Multi-Scale Structural Similarity
IW-SSIM 2011 Information Content Weighted Structural Similarity Index
VIFp 2004 Visual Information Fidelity
FSIM 2011 Feature Similarity Index Measure
SR-SIM 2012 Spectral Residual Based Similarity
GMSD 2013 Gradient Magnitude Similarity Deviation
MS-GMSD 2017 Multi-Scale Gradient Magnitude Similarity Deviation
VSI 2014 Visual Saliency-induced Index
DSS 2015 DCT Subband Similarity Index
- 2016 Content Score
- 2016 Style Score
HaarPSI 2016 Haar Perceptual Similarity Index
MDSI 2016 Mean Deviation Similarity Index
LPIPS 2018 Learned Perceptual Image Patch Similarity
PieAPP 2018 Perceptual Image-Error Assessment through Pairwise Preference
DISTS 2020 Deep Image Structure and Texture Similarity

No-Reference (NR)

Acronym Year Metric
TV 1937 Total Variation
BRISQUE 2012 Blind/Referenceless Image Spatial Quality Evaluator
CLIP-IQA 2022 CLIP-IQA

Distribution-Based (DB)

Acronym Year Metric
IS 2016 Inception Score
FID 2017 Frechet Inception Distance
GS 2018 Geometry Score
KID 2018 Kernel Inception Distance
MSID 2019 Multi-Scale Intrinsic Distance
PR 2019 Improved Precision and Recall

Benchmark

As part of our library we provide code to benchmark all metrics on a set of common Mean Opinon Scores databases. Currently we support several Full-Reference (TID2013, KADID10k and PIPAL) and No-Reference (KonIQ10k and LIVE-itW) datasets. You need to download them separately and provide path to images as an argument to the script.

Here is an example how to evaluate SSIM and MS-SSIM metrics on TID2013 dataset:

python3 tests/results_benchmark.py --dataset tid2013 --metrics SSIM MS-SSIM --path ~/datasets/tid2013 --batch_size 16

Below we provide a comparison between Spearman's Rank Correlation Coefficient (SRCC) values obtained with PIQ and reported in surveys. Closer SRCC values indicate the higher degree of agreement between results of computations on given datasets. We do not report Kendall rank correlation coefficient (KRCC) as it is highly correlated with SRCC and provides limited additional information. We do not report Pearson linear correlation coefficient (PLCC) as it's highly dependent on fitting method and is biased towards simple examples.

For metrics that can take greyscale or colour images, c means chromatic version.

Full-Reference (FR) Datasets

TID2013 KADID10k PIPAL
Source PIQ / Reference PIQ / Reference PIQ / Reference
PSNR 0.69 / 0.69 TID2013 0.68 / - 0.41 / 0.41 PIPAL
SSIM 0.72 / 0.64 TID2013 0.72 / 0.72 KADID10k 0.50 / 0.53 PIPAL
MS-SSIM 0.80 / 0.79 TID2013 0.80 / 0.80 KADID10k 0.55 / 0.46 PIPAL
IW-SSIM 0.78 / 0.78 Eval2019 0.85 / 0.85 KADID10k 0.60 / -
VIFp 0.61 / 0.61 TID2013 0.65 / 0.65 KADID10k 0.50 / -
FSIM 0.80 / 0.80 TID2013 0.83 / 0.83 KADID10k 0.59 / 0.60 PIPAL
FSIMc 0.85 / 0.85 TID2013 0.85 / 0.85 KADID10k 0.59 / -
SR-SIM 0.81 / 0.81 Eval2019 0.84 / 0.84 KADID10k 0.57 / -
SR-SIMc 0.87 / - 0.87 / - 0.57 / -
GMSD 0.80 / 0.80 MS-GMSD 0.85 / 0.85 KADID10k 0.58 / -
VSI 0.90 / 0.90 Eval2019 0.88 / 0.86 KADID10k 0.54 / -
DSS 0.79 / 0.79 Eval2019 0.86 / 0.86 KADID10k 0.63 / -
Content 0.71 / - 0.72 / - 0.45 / -
Style 0.54 / - 0.65 / - 0.34 / -
HaarPSI 0.87 / 0.87 HaarPSI 0.89 / 0.89 KADID10k 0.59 / -
MDSI 0.89 / 0.89 MDSI 0.89 / 0.89 KADID10k 0.59 / -
MS-GMSD 0.81 / 0.81 MS-GMSD 0.85 / - 0.59 / -
MS-GMSDc 0.89 / 0.89 MS-GMSD 0.87 / - 0.59 / -
LPIPS-VGG 0.67 / 0.67 DISTS 0.72 / - 0.57 / 0.58 PIPAL
PieAPP 0.84 / 0.88 DISTS 0.87 / - 0.70 / 0.71 PIPAL
DISTS 0.81 / 0.83 DISTS 0.88 / - 0.62 / 0.66 PIPAL
BRISQUE 0.37 / 0.84 Eval2019 0.33 / 0.53 KADID10k 0.21 / -
CLIP-IQA 0.50 / - 0.48 / - 0.26 / -
IS 0.26 / - 0.25 / - 0.09 / -
FID 0.67 / - 0.66 / - 0.18 / -
KID 0.42 / - 0.66 / - 0.12 / -
MSID 0.21 / - 0.32 / - 0.01 / -
GS 0.37 / - 0.37 / - 0.02 / -

No-Reference (NR) Datasets

KonIQ10k LIVE-itW
Source PIQ / Reference PIQ / Reference
BRISQUE 0.22 / - 0.31 / -
CLIP-IQA 0.68 / 0.68 CLIP-IQA off 0.64 / 0.64 CLIP-IQA off

Unlike FR and NR IQMs, designed to compute an image-wise distance, the DB metrics compare distributions of sets of images. To address these problems, we adopt a different way of computing the DB IQMs proposed in https://arxiv.org/abs/2203.07809. Instead of extracting features from the whole images, we crop them into overlapping tiles of size 96 ร— 96 with stride = 32. This pre-processing allows us to treat each pair of images as a pair of distributions of tiles, enabling further comparison. The other stages of computing the DB IQMs are kept intact.

Assertions

In PIQ we use assertions to raise meaningful messages when some component doesn't receive an input of the expected type. This makes prototyping and debugging easier, but it might hurt the performance. To disable all checks, use the Python -O flag: python -O your_script.py

Roadmap

See the open issues for a list of proposed features and known issues.

Contributing

If you would like to help develop this library, you'll find more information in our contribution guide.

Citation

If you use PIQ in your project, please, cite it as follows.

@misc{kastryulin2022piq,
  title = {PyTorch Image Quality: Metrics for Image Quality Assessment},
  url = {https://arxiv.org/abs/2208.14818},
  author = {Kastryulin, Sergey and Zakirov, Jamil and Prokopenko, Denis and Dylov, Dmitry V.},
  doi = {10.48550/ARXIV.2208.14818},
  publisher = {arXiv},
  year = {2022}
}
@misc{piq,
  title={{PyTorch Image Quality}: Metrics and Measure for Image Quality Assessment},
  url={https://github.com/photosynthesis-team/piq},
  note={Open-source software available at https://github.com/photosynthesis-team/piq},
  author={Sergey Kastryulin and Dzhamil Zakirov and Denis Prokopenko},
  year={2019}
}

Contacts

Sergey Kastryulin - @snk4tr - [email protected]

Jamil Zakirov - @zakajd - [email protected]

Denis Prokopenko - @denproc - [email protected]

piq's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

piq's Issues

Unify interfaces for FID and KID

Is your feature request related to a problem? Please describe.
Now these two measure have different high-level interfaces and work only with passed extracted features. Make it better.

Describe the solution you'd like
Create interfaces that allows to specify feature extractor, accept different types of collections of images etc.

Describe alternatives you've considered
None

Additional context
None

Add MSID metric

Is your feature request related to a problem? Please describe.
This metric showed to be comparable in quality of predictions with FID and KID scores.

Describe the solution you'd like
Take code from this repo https://github.com/xgfs/msid/tree/master/msid and potentially refactor it to make all FID, KID, MSID metrics interface look a like.

incorrect documentation regarding max_val in ssim

In SSIM documentation it is stated that one can specify the max_val argument.
However the current interface of the forward() function does not support it - it seems that max_val has been moved to initialization. The documentation (see link below) should reflect the current state.

https://github.com/photosynthesis-team/photosynthesis.metrics/blob/e17c4c1ddc19f282b12b232e4332f27b3291ea49/photosynthesis_metrics/ssim.py#L134

The same is true for MSSIM:
https://github.com/photosynthesis-team/photosynthesis.metrics/blob/e17c4c1ddc19f282b12b232e4332f27b3291ea49/photosynthesis_metrics/ssim.py#L317

Set up CI

Is your feature request related to a problem? Please describe.
Set up Continuous Integration with linting and running tests.

Describe the solution you'd like
Provide this functionality via Github Actions.

Describe alternatives you've considered
Travis CI or Drone CI if Github Actions will not work for some reason.

Additional context

PyTorch 1.4.0 support

Describe the bug
When use PyTorch 1.4.0, it fails to import in the CI testing pipeline. Example pipeline is here. The error started to occur in the day of PyTorch 1.4.0. release.

To Reproduce
Steps to reproduce the behavior:

  1. Go to requirements.txt
  2. Change required PyTorch version to 1.4.0
  3. Run $ pytest from the project folder
  4. See error

Expected behavior
No error expected to occur.

Screenshots
image

when used as loss, SSIM/MSSIM should be negative

SSIM and MSSIM currently compute the similarity index which is between 0 and 1, if arguments are given within correct ranges.

However, usually people minimize losses in Pytorch. So, unless they use the negative SSIM and MSSIM, they will end up with images that are dissimilar to their targets. I would suggest writing this word of advice somewhere in SSIM/MSSIM documentation or examples, just in case, for beginners, etc., e.g.:

If you want to train a neural network to produce images that are similar to your target, you should use SSIM or MSSIM losses with a negative sign.

Save my eyes

Is your feature request related to a problem? Please describe.
All files with metrics are named as their abbreviation except inception_score.py
image

Also rename Minimal examples in README.md

Describe the solution you'd like
Rename to isc.py or ins.py.

Additional context
It is not possible to name file is.py because then it will be impossible to import from it because is is a Python keyword.

Metric: Sum of gaussian derivatives

Is your feature request related to a problem? Please describe.
Implement metric described in the paper.

Describe the solution you'd like
Fix existing implementation or add a custom one.

Support weighted SSIM and MS-SSIM losses

Is your feature request related to a problem? Please describe.
First implementation of SSIM and MS-SSIM losses will be basic, treating each element of the batch equally. However, a user may want to weight items within batch as it can be done in BCELoss and some other losses in PyTorch.

Describe the solution you'd like
First, implement _WeightedLoss interface. Keep it protected since it is not supposed to be publicly accessed and only supposed to be used for the inheritance reasons. Take _WeightedLoss implementation in PyTorch as a reference

Describe alternatives you've considered

Additional context

Add tests to the MS-SSIM implementation

Is your feature request related to a problem? Please describe.
MS-SSIM implementation need to be tested in order to show its correctness and provide a better environment for the refactoring.

Asserting minimal image resolution for MS-SSIM computation

Is your feature request related to a problem? Please describe.
Currently is low resolution image/set of images is passed to the MultiScaleSSIMLoss it crashes with the default PyTorch stack trace, which can be hard to interpret

Describe the solution you'd like
Find out the minimal allowed resolution and introduce an assertion/check of image resolution before it is passed to the MS-SSIM computation code.

Pull request templates

Is your feature request related to a problem? Please describe.
Now PRs are unstructured, which makes ideas behind them less clear and harder to understand.

Describe the solution you'd like
Adjust one of the common templates to meet the needs of our project.

Measure: Perceptual Scores

Is your feature request related to a problem? Please describe.
Need to add two types of perceptual scores: content score and style score. Both scores might be needed both and measures and as losses.

Describe the solution you'd like
Add both measures based on implementation by @zakajd. Improvements to be made:

  • Readable layer names. They are needed for better understanding of what layers are used.
  • Normalization of values in layers if several layers are used.

Add automatic deployment to conda

Is your feature request related to a problem? Please describe.
It is convenient to have our lib to be available both in pip and conda.

Describe the solution you'd like
Add new CD file, provide required configurations.

New measure: inception score

Is your feature request related to a problem? Please describe.
Inception score is a popular measure in the GAN world, hence need to be added.

Describe the solution you'd like
Implement from scratch or adapt external implementation. Support BaseFeatureMetric interface.

Introduce convolution with Gaussian kernels to `utils.py`

Background
Current implementations of VIF and SSIM/MS-SSIM losses share the same functionality - 2D convolution with Gaussian kernel.

Idea
Optimise the code by moving the mentioned methods to utils.py.

Outcomes

  • No duplicates of code
  • Better readability

Strange TV loss

What is the purpose of defining the TV loss as the absolute difference between the Total Variations of predicted tensor and the target one? Usually, TV used as a regularizer applied only to the predicted tensor.

I can make a pull request with the correction.

Remove redundancy in TV

Is your feature request related to a problem? Please describe.
Now we have total_variation metric and TVLoss, which are exactly the same things.

Describe the solution you'd like
One of entities needs to removed. Another, probably, renamed.

Get rid of redundant libraries like scipy

Is your feature request related to a problem? Please describe.
Currently some implementations use libraries for computations on CPU like scipy.

Describe the solution you'd like
Refactor the code in such a way that it will work without them.

Unify SSIM/MS-SSIM and their losses in terms of supported tensor sizes

Is your feature request related to a problem? Please describe.
Currently SSIM/MS-SSIM losses try to work with 2, 3, 4-dimensional tensors, but corresponding measures support only 4D. Unify that.

Describe the solution you'd like
Provide interface for the unification.

Describe alternatives you've considered
None

Additional context
None

CD - publishing to pypi

Is your feature request related to a problem? Please describe.
The library need to be published to pypi package manager in order to become easier to be installed.

Describe the solution you'd like
Decide on internal package name. Now it is called metrics but it might be changed to something less common in order to avoid collisions.

Describe alternatives you've considered
None

Additional context
None

Unify input tensor validation and dimension adjustments for losses.

Problem
Current implementation (after #58) uses not optimised validation of input tensors and their dimension adjustments as different number of inputs can be provided.

Solution
Unify the interface for input validations:

  • Introduce validation method for a single input;
  • Change validation of method of 2 inputs using methods mentioned above;
  • Do the same for dimension adjustments.

Same values for `mean` and `sum` reductions of TV loss.

Describe the bug
Reductions at TVLoss return the same value, when default parameters are used to initialise TVLoss()

To Reproduce

from photosynthesis_metrics import TVLoss
import torch
torch.manual_seed(42)
a = torch.rand(3,3,256,256)
print(f'mean reduction: {TVLoss(reduction='mean')(a)}')
print(f'sum reduction: {TVLoss(reduction='sum')(a)}')

Output

>>> mean reduction: 255.3401
>>> sum reduction: 255.3401

Expected behavior
Output

>>> mean reduction: 255.3401
>>> sum reduction: 766.0204

Solution

  • Get rid of size_average parameter at TVLoss;
  • Call total_variation with size_average=False at TVLoss().forward()

Update TV interface

Is your feature request related to a problem? Please describe.
TV metric and loss were meant to be unified (#76). It meant that function will be removed so it was not updated to work with 2/3/4D tensors.
However, it was decided to not to do that and now TV needs an update.

Describe the solution you'd like

  • Move validate_input and adjust_dimensions to the total_variation function
  • Call total_variation with all required checks from TVLoss

Reimplement KID in PyTorch

Is your feature request related to a problem? Please describe.
Official KID implementation is in numpy which may make it slower then it could be. We also would like to avoid additional dependency.

Describe the solution you'd like
Replace numpy and sklearn functions with PyTorch and perform other required changes.

Describe alternatives you've considered
None

Additional context
None

Workflows are not running in PRs

Describe the bug
If PR is introduced from a fork, the results of workflows are not visible in the PR.

To Reproduce
Steps to reproduce the behavior:

  1. Fork the repo
  2. Introduce your changes
  3. Make PR
  4. See that no workflows were run even though they were

Expected behavior
Workflows are running the same way as they do in case of PRs from branches in the repo

Solve adjust dimentions/validate input problem

Is your feature request related to a problem? Please describe.
Currently, not feature-based methods perform two steps before actual computation of metrics: adjustment of dimensions (which is meant to make processing of tensors with different number of dimensions possible) and validation of input (which is meant to validate correctness of user's input). However, their existing implementations contradict to each other: the validation function validates that user's input is 4-dimensional while adjust_dimention changes user's input to be 4-dimensional. This behaviour is redundant and introduces extra confusion.

Describe the solution you'd like

  • Remove check that user's input is 4-dimensional
  • Make sure that adjust_dimentions functionality works as expected (introduce extra tests)
  • Implement all above for all not feature-based metrics

Additional context
It is important to keep in mind #6. We would like to work not only with 4-dimensional tensors because in some applications like medical imaging 5D tensors are used. It is also sometimes convenient for a user to pass 2D or 3D tensors and not perform adjustment themselves.

MS-SSIM returns wrong values

Describe the bug
multi_scale_ssim and MultiScaleLoss appear to estimate wrong values compared to results obtained from official TensorFlow implementation.

To Reproduce

from photosynthesis_metrics import multi_scale_ssim, MultiScaleSSIMLoss
import torch
import tensorflow as tf
from time import time
torch.manual_seed(42)
for _ in range(2):
    a = torch.rand(3, 3, 256, 256)
    b = torch.rand(3, 3, 256, 256)
    start = time()
    ps_ms_ssim = multi_scale_ssim(a,b, kernel_size=11, kernel_sigma=1.5, size_average=False, data_range=1.).numpy()
    ps_time = time()-start
    start = time()
    ps_ms_ssim_loss = MultiScaleSSIMLoss( kernel_size=11, kernel_sigma=1.5, data_range=1.)(a, b).numpy()
    ps_loss_time = time() - start
    tf_a = tf.convert_to_tensor(a.permute(0, 2, 3, 1).numpy())
    tf_b = tf.convert_to_tensor(b.permute(0, 2, 3, 1).numpy())
    start = time()
    tf_ms_ssim = tf.image.ssim_multiscale(tf_a, tf_b, max_val=1., filter_size=11, filter_sigma=1.5).numpy()
    tf_time = time() - start
    print(f'photosynthesis result: {ps_ms_ssim}, time: {ps_time}s')
    print(f'tensorflow result: {tf_ms_ssim}, time: {tf_time}s\n')
    print(f'photosynthesis loss result: {ps_ms_ssim_loss}, time: {ps_loss_time}s')
    print(f'tensorflow result: {tf_ms_ssim.mean()}, time: {tf_time}s\n')

Output

>>>photosynthesis result: [0.06354865 0.06629971 0.07052894], time: 0.20274901390075684s
>>>tensorflow result: [0.05706326 0.08324481 0.08343431], time: 1.2265629768371582s

>>>photosynthesis loss result: 0.06679243594408035, time: 0.18335914611816406s
>>>tensorflow result: 0.07458078861236572, time: 1.2265629768371582s

>>>photosynthesis result: [0.06800205 0.07029662 0.07833724], time: 0.19111299514770508s
>>>tensorflow result: [0.08063222 0.08336634 0.09324924], time: 1.2148618698120117s

>>>photosynthesis loss result: 0.07221197336912155, time: 0.20091605186462402s
>>>tensorflow result: 0.08574926853179932, time: 1.2148618698120117s

Expected behavior
Same values are expected.

Additional context
The bug was found during inspection of issue #13 . I assume the problem is located at _compute_multi_scale_ssim. Possible fail points:

  1. In the TensorFlow implementation of MS-SSIM, SSIM appears to return tensor of (batch, channels), while in current implementation tensor has only (batch) dimension.
  2. First, the product should be estimated. Then, the result should be averaged along channel dimension. Current implementation performs it vice versa.

Unify interface for feature metrics, remove redundant code

Is your feature request related to a problem? Please describe.
Right now for all metrics, that require features, there is exist a function to compute it AND a class, which both have almost the same functionality. The only difference is that inside a class there is also an option to precompute features from an image.

Describe the solution you'd like
Idea is to move everything related to metric computation into compute_metric class method,
make a unified forward call which takes torch.Tensors and return torch.Tensor, moves them from GPU device to CPU and detaches if needed.

Describe alternatives you've considered
Alternatively, we could add an option to automatically turn images into features inside a class forward call, but as discussed with @snk4tr, initially proposed solution is better.

CD - building docs

Is your feature request related to a problem? Please describe.
Create a separate external hosted documentation site.

Describe the solution you'd like
Use recommendations from here - Sphinx as a documentation generator and Read the Docs as a free hosting engine.

Describe alternatives you've considered
No other options under consideration at the moment.

Additional context
None

Feature: LPIPS metric/loss

Is your feature request related to a problem? Please describe.
Add LPIPS measure, which is somewhat similar to Perceptual score.
Differences:

  • Predictions are made on image patches
  • Weights for different feature maps are learnable
  • Feature maps are normalized to have same scale.

Describe the solution you'd like
Adjust code from official implementation repo: https://github.com/richzhang/PerceptualSimilarity

This should be closed before #26 , because then Perceptual score can be inherited from this score with some parameters fixed.

Update readme with API description and examples

Is your feature request related to a problem? Please describe.
Currently there is no way to understand which interfaces are available and how to use them without reading code.

Describe the solution you'd like
Update readme with API description and examples.

Add support of 5D tensors in SSIM and MS-SSIM

Is your feature request related to a problem? Please describe.
Current implementation supports only 2, 3, and 4 dimensional tensors. However, in some domains like medical imaging it may be useful to be able to work with 5D tensors out of the box.

Describe the solution you'd like
Fix the _compute_ssim and _compute_multi_scale_ssim functions so they can handle 5D.

Describe alternatives you've considered
Fix top-level functions to make then iterate over the extra dimension and then reduce.

Additional context

Documentation for Geometry Score

Is your feature request related to a problem? Please describe.
There is no documentation for GS in Readme

Describe the solution you'd like
Add documentation for GS in Readme as it is done for other metrics

Additional context
Note that documentation has to be added in the same PR as the new metric itself

Add tests to make sure that minimal examples work

Is your feature request related to a problem? Please describe.
With minimal examples added in #24 there is a risk that some of them may not work after some API changes or due to other problems.

Describe the solution you'd like
Add automatic tests that will verify that minimal examples work correctly.

Fully migrate GS from numpy to pytorch

Is your feature request related to a problem? Please describe.
As stated in #41 GS is computationally intense and this problem is solved now with CPU multiprocessing. Migration to PyTorch may help to solve this problem. It will also make code simpler due to the lack of error-prone multiprocessing.

Tests to compare present SSIM and MS-SSIM implementations with other implementations

Is your feature request related to a problem? Please describe.
Currently there is no proof that our SSIM and MS-SSIM metrics are correct and give values consistent with official CPU implementations. Such tests need to be added.

Describe the solution you'd like
Take official and our implementations and run them on several different objects and problems. Compare results. Results need to be identical up to floating point operations error or another understandable error gap.

Describe alternatives you've considered
None

Additional context
None

CI: make formatting verifications more strict

Currently, linter check within the CI pipeline performs only very basic checks like line length being <120 symbols. PR review process shows that the majority of feedback in related to code style and formatting issues, which can be automated. Make checks more strict and descriptive.

Slow InceptionV3 initialisation

Describe the bug
Model init for InceptionV3 model both from this repo and from torchvision.models take very long time. Usually ~180-200 seconds, while other models init in 2-3 sec.
Problem arose a couple of month ago and discussed here

To Reproduce

from torchvision.models import inception_v3  
import photosynthesis_metrics as pm
import scipy
print(scipy.__version__)

model = inception_v3(pretrained=True, transform_input=True, progress=True)
pm_model = pm.feature_extractors.fid_inception.InceptionV3(
    resize_input=True, 
    normalize_input=True,
    requires_grad=False,
    use_fid_inception=True,
)

This could should take around 6 minutes to complete (3 minutes per model).

Expected behaviour
Fast model initialisation, not longer than a couple of seconds.

Fix
Problem comes from scipy package with version 1.4.1 defined in requirements.txt.
Uninstalling newer version and installing 1.3.3 fixed the issue for me. The loading time is much faster now. Just had to do pip install --upgrade scipy==1.3.3

Proposed solution
Change version in requirements.txt
This will increase testing speed 10x (now all tests run in 10 minutes, because of 3 model inits, after fix they will run in 1 minute).

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.