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

UniversalImageQualityIndex & SpectralDistortionIndex are still possible to give NaN results #2221

Closed
michael080808 opened this issue Nov 18, 2023 · 1 comment · Fixed by #2222
Labels
bug / fix Something isn't working help wanted Extra attention is needed v1.2.x

Comments

@michael080808
Copy link

michael080808 commented Nov 18, 2023

🐛 Bug

I noticed the issue #1520.
The fix may still cause "divided by zero" problem because eps is not directly added to the divisor.

To Reproduce

    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)

Here (mu_pred_sq + mu_target_sq) * lower still may contain zero values. For example, if there are several pictures with large black area, both mu_pred_sq and mu_target_sq can be zeros. To reproduce the problem, these two images can be as examples.

Example
Example

Expected behavior

    upper = 2 * sigma_pred_target
    lower = sigma_pred_sq + sigma_target_sq

    uqi_idx = ((2 * mu_pred_target) * upper) / ((mu_pred_sq + mu_target_sq) * lower + torch.finfo(lower.dtype).eps)

This fix is very easy to understand. Just thanks to your excellent jobs!

Environment

Name Version Build Channel
_anaconda_depends 2023.07 py311_0 https://repo.anaconda.com/pkgs/main
conda 23.9.0 py311haa95532_0 https://repo.anaconda.com/pkgs/main
python 3.10.13 he1021f5_0 defaults
pytorch 2.1.0 py3.10_cuda12.1_cudnn8_0 pytorch
pytorch-cuda 12.1 hde6ce7c_5 pytorch
pytorch-mutex 1.0 cuda pytorch
torchaudio 2.1.0 pypi_0 pypi
torchmetrics 1.2.0 pyhd8ed1ab_0 conda-forge
torchvision 0.16.0 pypi_0 pypi
@michael080808 michael080808 added bug / fix Something isn't working help wanted Extra attention is needed labels Nov 18, 2023
Copy link

Hi! thanks for your contribution!, great first issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug / fix Something isn't working help wanted Extra attention is needed v1.2.x
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants