jpxkqx's picture
Update contents
9fd6c68

A newer version of the Gradio SDK is available: 5.4.0

Upgrade
metadata
title: Peak Signal to Noise Ratio
tags:
  - evaluate
  - metric
description: Image quality metric
sdk: gradio
sdk_version: 3.0.2
app_file: app.py
pinned: false

Metric Card for Peak Signal to Noise Ratio

Metric Description

It is the ratio between the maximum possible power of a signal and the power of corrupting noise that affects the fidelity of its representation. This metric is commonly used to measure the quality of images generated by models.

  • Super-Resolution
  • Image Denoising
  • Image Compression

PSNR is a measure of the quality of reconstruction of an image. The higher the PSNR, the better the quality of the image.

How to Use

At minimum, this metric requires predictions and references as inputs.

import evaluate

psnr = evaluate.load("jpxkqx/peak_signal_to_noise_ratio")
psnr.compute(predictions=[[0.0, 0.1], [0.1, 0.9]], references=[[0.0, 0.2], [0.1, 0.8]])

Inputs

  • predictions ('np.array'): Predictions to evaluate.
  • references ('np.array'): True image to consider as baseline.
  • data_range ('float'): The data range of the images (distance between the minimum and maximum possible values). If not provided, it is determined from the image data-type.
  • sample_weight ('list'): Sample weights default to None.

Output Values

  • psnr ('float'): Peak Signal to Noise Ratio, which it is expressed as a logarithmic quantity using the decibel scale.

Outputs example:

{'psnr': 35.23}

Typical values for the PSNR in lossy image and video compression are between 30 and 50 dB, provided the bit depth is 8 bits.

Further References

Peak Signal to Noise Ratio (PSNR) - Wikipedia Peak Signal to Noise Ratio (PSNR) - scikit-image Peak Signal to Noise Ratio (PSNR) - PyTorch Peak Signal to Noise Ratio (PSNR) - TensorFlow