Skip to content

Commit

Permalink
Merge branch 'newmetric/nrmse' of https://github.com/Lightning-AI/tor…
Browse files Browse the repository at this point in the history
…chmetrics into newmetric/nrmse
  • Loading branch information
SkafteNicki committed Oct 19, 2024
2 parents 67925cb + 1e716de commit 19c3ef2
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docs-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
retention-days: ${{ steps.keep-artifact.outputs.DAYS }}

- name: update cashing
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && matrix.target == 'html' }}
continue-on-error: true
uses: ./.github/actions/push-caches
with:
Expand Down
39 changes: 20 additions & 19 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,52 +12,53 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Added a new audio metric `DNSMOS` ([#2525](https://github.com/PyTorchLightning/metrics/pull/2525))

- Added `NormalizedRootMeanSquaredError` metric to regression subpackage ([#2442](https://github.com/Lightning-AI/torchmetrics/pull/2442))

- Added `MetricInputTransformer` wrapper ([#2392](https://github.com/Lightning-AI/torchmetrics/pull/2392))

### Changed

- Added `input_format` argument to segmentation metrics ([#2572](https://github.com/Lightning-AI/torchmetrics/pull/2572))
-


- Added multi-output support for MAE metric ([#2605](https://github.com/Lightning-AI/torchmetrics/pull/2605))
### Removed

-

- Added new metric `ProcrustesDistance` to new domain Shape ([#2723](https://github.com/Lightning-AI/torchmetrics/pull/2723)

### Fixed

- Added `truncation` argument to `BERTScore` ([#2776](https://github.com/Lightning-AI/torchmetrics/pull/2776))
-


- Added `NormalizedRootMeanSquaredError` metric to regression subpackage ([#2442](https://github.com/Lightning-AI/torchmetrics/pull/2442))
---

## [1.5.0] - 2024-10-18

- Added `HausdorffDistance` to segmentation package ([#2122](https://github.com/Lightning-AI/torchmetrics/pull/2122))
### Added

- Added segmentation metric `HausdorffDistance` ([#2122](https://github.com/Lightning-AI/torchmetrics/pull/2122))
- Added audio metric `DNSMOS` ([#2525](https://github.com/PyTorchLightning/metrics/pull/2525))
- Added shape metric `ProcrustesDistance` ([#2723](https://github.com/Lightning-AI/torchmetrics/pull/2723)
- Added `MetricInputTransformer` wrapper ([#2392](https://github.com/Lightning-AI/torchmetrics/pull/2392))
- Added `input_format` argument to segmentation metrics ([#2572](https://github.com/Lightning-AI/torchmetrics/pull/2572))
- Added `multi-output` support for MAE metric ([#2605](https://github.com/Lightning-AI/torchmetrics/pull/2605))
- Added `truncation` argument to `BERTScore` ([#2776](https://github.com/Lightning-AI/torchmetrics/pull/2776))

### Changed

- Tracker higher is better integration ([#2649](https://github.com/Lightning-AI/torchmetrics/pull/2649))


- Updated `InfoLM` class to dynamically set `higher_is_better` ([#2674](https://github.com/Lightning-AI/torchmetrics/pull/2674))


### Deprecated

- Deprecated `num_outputs` in `R2Score` ([#2705](https://github.com/Lightning-AI/torchmetrics/pull/2705))


### Removed

-


### Fixed

- Fixed corner case in `Iou` metric for single empty prediction tensors ([#2780](https://github.com/Lightning-AI/torchmetrics/pull/2780))
- Fixed corner case in `IoU` metric for single empty prediction tensors ([#2780](https://github.com/Lightning-AI/torchmetrics/pull/2780))
- Fixed `PSNR` calculation for integer type input images ([#2788](https://github.com/Lightning-AI/torchmetrics/pull/2788))

---

## [1.4.3] - 2024-10-10

Expand Down
3 changes: 3 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,4 +447,7 @@ def linkcode_resolve(domain, info) -> Optional[str]: # noqa: ANN001
"https://aclanthology.org/W17-4770",
# A wavelet transform method to merge Landsat TM and SPOT panchromatic data
"https://www.ingentaconnect.com/content/tandf/tres/1998/00000019/00000004/art00013",
# todo: these links seems to be unstable, referring to .devcontainer
"https://code.visualstudio.com",
"https://code.visualstudio.com/.*",
]
2 changes: 1 addition & 1 deletion src/torchmetrics/__about__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "1.5.0dev"
__version__ = "1.6.0dev"
__author__ = "Lightning-AI et al."
__author_email__ = "name@pytorchlightning.ai"
__license__ = "Apache-2.0"
Expand Down
5 changes: 5 additions & 0 deletions src/torchmetrics/functional/image/psnr.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ def _psnr_update(
Default is None meaning scores will be reduced across all dimensions.
"""
if not preds.is_floating_point():
preds = preds.to(torch.float32)
if not target.is_floating_point():
target = target.to(torch.float32)

if dim is None:
sum_squared_error = torch.sum(torch.pow(preds - target, 2))
num_obs = tensor(target.numel(), device=target.device)
Expand Down
13 changes: 13 additions & 0 deletions tests/unittests/image/test_psnr.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,16 @@ def test_missing_data_range():

with pytest.raises(ValueError, match="The `data_range` must be given when `dim` is not None."):
peak_signal_noise_ratio(_inputs[0].preds, _inputs[0].target, data_range=None, dim=0)


def test_psnr_uint_dtype():
"""Check that automatic casting to float is done for uint dtype.
See issue: https://github.com/Lightning-AI/torchmetrics/issues/2787
"""
preds = torch.randint(0, 255, _input_size, dtype=torch.uint8)
target = torch.randint(0, 255, _input_size, dtype=torch.uint8)
psnr = peak_signal_noise_ratio(preds, target)
prnr2 = peak_signal_noise_ratio(preds.float(), target.float())
assert torch.allclose(psnr, prnr2)

0 comments on commit 19c3ef2

Please sign in to comment.