Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move functional psnr & ssim to image #382

Merged
merged 9 commits into from
Jul 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Moved `psnr` and `ssim` from `torchmetrics.functional.regression.*` to `torchmetrics.functional.image.*` ([#382](https://github.com/PyTorchLightning/metrics/pull/382)):


### Deprecated

Expand All @@ -33,6 +35,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Removed restriction that `preds` could not be bigger than `num_classes` to support logit input ([#357](https://github.com/PyTorchLightning/metrics/pull/357))


- Removed module `torchmetrics.regression.psnr` and `torchmetrics.regression.ssim` ([#382](https://github.com/PyTorchLightning/metrics/pull/382)):


### Fixed


Expand Down
32 changes: 18 additions & 14 deletions docs/source/references/functional.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,24 @@ snr [func]
.. autofunction:: torchmetrics.functional.snr
:noindex:

*************
Image Metrics
*************


psnr [func]
Borda marked this conversation as resolved.
Show resolved Hide resolved
~~~~~~~~~~~

.. autofunction:: torchmetrics.functional.psnr
:noindex:


ssim [func]
~~~~~~~~~~~

.. autofunction:: torchmetrics.functional.ssim
:noindex:


**********************
Classification Metrics
Expand Down Expand Up @@ -254,13 +272,6 @@ pearson_corrcoef [func]
:noindex:


psnr [func]
~~~~~~~~~~~

.. autofunction:: torchmetrics.functional.psnr
:noindex:


r2score [func]
~~~~~~~~~~~~~~

Expand All @@ -275,13 +286,6 @@ spearman_corrcoef [func]
:noindex:


ssim [func]
~~~~~~~~~~~

.. autofunction:: torchmetrics.functional.ssim
:noindex:


symmetric_mean_absolute_percentage_error [func]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
28 changes: 14 additions & 14 deletions docs/source/references/modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,20 @@ KID
.. autoclass:: torchmetrics.KID
:noindex:


PSNR
~~~~

.. autoclass:: torchmetrics.PSNR
:noindex:


SSIM
~~~~

.. autoclass:: torchmetrics.SSIM
:noindex:

******************
Regression Metrics
******************
Expand Down Expand Up @@ -375,13 +389,6 @@ PearsonCorrcoef
:noindex:


PSNR
~~~~

.. autoclass:: torchmetrics.PSNR
:noindex:


R2Score
~~~~~~~

Expand All @@ -395,13 +402,6 @@ SpearmanCorrcoef
.. autoclass:: torchmetrics.SpearmanCorrcoef
:noindex:


SSIM
~~~~

.. autoclass:: torchmetrics.SSIM
:noindex:

SymmetricMeanAbsolutePercentageError
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
4 changes: 1 addition & 3 deletions torchmetrics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,9 @@
StatScores,
)
from torchmetrics.collections import MetricCollection # noqa: F401 E402
from torchmetrics.image import FID, IS, KID # noqa: F401 E402
from torchmetrics.image import FID, IS, KID, PSNR, SSIM # noqa: F401 E402
from torchmetrics.metric import Metric # noqa: F401 E402
from torchmetrics.regression import ( # noqa: F401 E402
PSNR,
SSIM,
CosineSimilarity,
ExplainedVariance,
MeanAbsoluteError,
Expand Down
4 changes: 2 additions & 2 deletions torchmetrics/functional/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
from torchmetrics.functional.classification.roc import roc # noqa: F401
from torchmetrics.functional.classification.specificity import specificity # noqa: F401
from torchmetrics.functional.classification.stat_scores import stat_scores # noqa: F401
from torchmetrics.functional.image.psnr import psnr # noqa: F401
from torchmetrics.functional.image.ssim import ssim # noqa: F401
from torchmetrics.functional.image_gradients import image_gradients # noqa: F401
from torchmetrics.functional.nlp import bleu_score # noqa: F401
from torchmetrics.functional.regression.cosine_similarity import cosine_similarity # noqa: F401
Expand All @@ -44,10 +46,8 @@
from torchmetrics.functional.regression.mean_squared_error import mean_squared_error # noqa: F401
from torchmetrics.functional.regression.mean_squared_log_error import mean_squared_log_error # noqa: F401
from torchmetrics.functional.regression.pearson import pearson_corrcoef # noqa: F401
from torchmetrics.functional.regression.psnr import psnr # noqa: F401
from torchmetrics.functional.regression.r2 import r2_score, r2score # noqa: F401
from torchmetrics.functional.regression.spearman import spearman_corrcoef # noqa: F401
from torchmetrics.functional.regression.ssim import ssim # noqa: F401
from torchmetrics.functional.regression.symmetric_mean_absolute_percentage_error import ( # noqa: F401
symmetric_mean_absolute_percentage_error,
)
Expand Down
15 changes: 15 additions & 0 deletions torchmetrics/functional/image/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright The PyTorch Lightning team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from torchmetrics.functional.image.psnr import psnr # noqa: F401
4 changes: 2 additions & 2 deletions torchmetrics/functional/regression/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from torchmetrics.functional.image.psnr import psnr # noqa: F401
from torchmetrics.functional.image.ssim import ssim # noqa: F401
from torchmetrics.functional.regression.cosine_similarity import cosine_similarity # noqa: F401
from torchmetrics.functional.regression.explained_variance import explained_variance # noqa: F401
from torchmetrics.functional.regression.mean_absolute_error import mean_absolute_error # noqa: F401
Expand All @@ -20,7 +22,5 @@
from torchmetrics.functional.regression.mean_squared_error import mean_squared_error # noqa: F401
from torchmetrics.functional.regression.mean_squared_log_error import mean_squared_log_error # noqa: F401
from torchmetrics.functional.regression.pearson import pearson_corrcoef # noqa: F401
from torchmetrics.functional.regression.psnr import psnr # noqa: F401
from torchmetrics.functional.regression.r2 import r2_score # noqa: F401
from torchmetrics.functional.regression.spearman import spearman_corrcoef # noqa: F401
from torchmetrics.functional.regression.ssim import ssim # noqa: F401
2 changes: 1 addition & 1 deletion torchmetrics/image/psnr.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import torch
from torch import Tensor, tensor

from torchmetrics.functional.regression.psnr import _psnr_compute, _psnr_update
from torchmetrics.functional.image.psnr import _psnr_compute, _psnr_update
from torchmetrics.metric import Metric
from torchmetrics.utilities import rank_zero_warn

Expand Down
2 changes: 1 addition & 1 deletion torchmetrics/image/ssim.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import torch
from torch import Tensor

from torchmetrics.functional.regression.ssim import _ssim_compute, _ssim_update
from torchmetrics.functional.image.ssim import _ssim_compute, _ssim_update
from torchmetrics.metric import Metric
from torchmetrics.utilities import rank_zero_warn
from torchmetrics.utilities.data import dim_zero_cat
Expand Down
2 changes: 0 additions & 2 deletions torchmetrics/regression/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@
from torchmetrics.regression.mean_squared_error import MeanSquaredError # noqa: F401
from torchmetrics.regression.mean_squared_log_error import MeanSquaredLogError # noqa: F401
from torchmetrics.regression.pearson import PearsonCorrcoef # noqa: F401
from torchmetrics.regression.psnr import PSNR # noqa: F401
from torchmetrics.regression.r2score import R2Score # noqa: F401
from torchmetrics.regression.spearman import SpearmanCorrcoef # noqa: F401
from torchmetrics.regression.ssim import SSIM # noqa: F401
from torchmetrics.regression.symmetric_mean_absolute_percentage_error import ( # noqa: F401
SymmetricMeanAbsolutePercentageError,
)
49 changes: 0 additions & 49 deletions torchmetrics/regression/psnr.py

This file was deleted.

53 changes: 0 additions & 53 deletions torchmetrics/regression/ssim.py

This file was deleted.