How to save pictures in TensorFlow
TensorFlow how to save pictures, I believe that many inexperienced people do not know what to do, so this article summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.
# read the picture according to the path img = tf.io.read_file (img_path) # decode the picture It should be decoded into the png format img = tf.image.decode_png (img, channels=1) # size scaling img = tf.image.resize (img, [28,28]) # this step of converting the tensor data type is very important img = tf.cast (img, dtype=tf.uint8) # Encoding back to the picture img = tf.image.encode_png (img) # Save with tf.io.gfile.GFile (img_path 'wb') as file: file.write (img.numpy ()) finished reading the above Have you mastered how to save pictures in TensorFlow? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!