Skip to content

Commit

Permalink
Move eps in UniversalQualityIndex (Lightning-AI#2222)
Browse files Browse the repository at this point in the history
Co-authored-by: Jirka Borovec <6035284+Borda@users.noreply.github.com>
  • Loading branch information
SkafteNicki and Borda authored Nov 21, 2023
1 parent d34e92f commit bcf7867
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- Fixed numerical stability bug in `LearnedPerceptualImagePatchSimilarity` metric ([#2144](https://github.com/Lightning-AI/torchmetrics/pull/2144))
- Fixed numerical stability bug in `LearnedPerceptualImagePatchSimilarity` metric ([#2144](https://github.com/Lightning-AI/torchmetrics/pull/2144))


- Fixed numerical stability issue in `UniversalImageQualityIndex` metric ([#2222](https://github.com/Lightning-AI/torchmetrics/pull/2222))


## [1.2.0] - 2023-09-22
Expand Down
6 changes: 3 additions & 3 deletions src/torchmetrics/functional/image/uqi.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ def _uqi_compute(
sigma_pred_target = output_list[4] - mu_pred_target

upper = 2 * sigma_pred_target
lower = sigma_pred_sq + sigma_target_sq + torch.finfo(sigma_pred_sq.dtype).eps

uqi_idx = ((2 * mu_pred_target) * upper) / ((mu_pred_sq + mu_target_sq) * lower)
lower = sigma_pred_sq + sigma_target_sq
eps = torch.finfo(sigma_pred_sq.dtype).eps
uqi_idx = ((2 * mu_pred_target) * upper) / ((mu_pred_sq + mu_target_sq) * lower + eps)
uqi_idx = uqi_idx[..., pad_h:-pad_h, pad_w:-pad_w]

return reduce(uqi_idx, reduction)
Expand Down

0 comments on commit bcf7867

Please sign in to comment.