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

Clamp image before PSNR and MS-SSIM #1592

Closed
Freed-Wu opened this issue Mar 6, 2023 · 0 comments · Fixed by #1606
Closed

Clamp image before PSNR and MS-SSIM #1592

Freed-Wu opened this issue Mar 6, 2023 · 0 comments · Fixed by #1606
Labels
enhancement New feature or request topic: Image
Milestone

Comments

@Freed-Wu
Copy link
Contributor

Freed-Wu commented Mar 6, 2023

🚀 Feature

from torchmetrics.image.psnr import PeakSignalNoiseRatio

metric = PeakSignalNoiseRatio(clamp=[0, 1])
for inputs, targets in dataloader:
    outputs = model(inputs)
    metric(outputs, targets)

Then we will clamp images to $[0, 1]$, and calculate data_range = 1 - 0.

Motivation

Image have a legal range, $[0, 255]$ or $[0, 1]$, so a clamp is necessary for calculate PSNR.

Pitch

Alternatives

from torchmetrics.image.psnr import PeakSignalNoiseRatio

metric = PeakSignalNoiseRatio(data_range=[0, 1])
for inputs, targets in dataloader:
    outputs = model(inputs)
    metric(outputs, targets)

if data_range is a int, it keep same behaviour as before. if it is a list, will clamp image to data_range and calculate its delta as data_range.

Additional context

@Freed-Wu Freed-Wu added the enhancement New feature or request label Mar 6, 2023
@SkafteNicki SkafteNicki added this to the v0.12 milestone Mar 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request topic: Image
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants