Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to save pictures in TensorFlow

Shulou Source: shulou.com Published: 2022-06-01 09:00:44 09月26日 Update

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!

Tags: Picture content method more problem important helpless for this reason size this tensor skill data format article type experience coding industry Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft macOS Redmi MySQL Shulou Tech Info