--- 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. ```python 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: ```python {'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](https://en.wikipedia.org/wiki/Peak_signal-to-noise_ratio) [Peak Signal to Noise Ratio (PSNR) - scikit-image](https://scikit-image.org/docs/dev/api/skimage.metrics.html#skimage.metrics.peak_signal_noise_ratio) [Peak Signal to Noise Ratio (PSNR) - PyTorch](https://pytorch.org/ignite/generated/ignite.metrics.PSNR.html) [Peak Signal to Noise Ratio (PSNR) - TensorFlow](https://www.tensorflow.org/api_docs/python/tf/image/psnr)