File size: 355 Bytes
2673600
 
 
 
 
 
 
 
 
6fd61b9
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import tensorflow as tf


def read_image(image_path):
    image = tf.io.read_file(image_path)
    image = tf.image.decode_png(image, channels=3)
    image.set_shape([None, None, 3])
    image = tf.cast(image, dtype=tf.float32) / 255.0
    return image


def peak_signal_noise_ratio(y_true, y_pred):
    return tf.image.psnr(y_pred, y_true, max_val=255.0)