Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. import tensorflow as tf
  2. import matplotlib.pyplot as plt
  3. import numpy as np
  4. import os
  5. %matplotlib inline
  6.  
  7. path = './Test_Dataset_png'
  8. file_paths = [os.path.join(path, filename)
  9. for filename in os.listdir(path)]
  10.  
  11. tf.reset_default_graph()
  12. filename_queue = tf.train.string_input_producer(file_paths)
  13.  
  14. reader = tf.WholeFileReader()
  15. key, value = reader.read(filename_queue)
  16. decoded_img = tf.image.decode_png(value)
  17.  
  18. decoded_img = tf.reduce_mean(decoded_img, axis=-1)
  19.  
  20. with tf.Session() as sess:
  21. coord = tf.train.Coordinator()
  22. thread = tf.train.start_queue_runners(sess, coord)
  23.  
  24. image = sess.run(decoded_img)
  25. print(image.shape)
  26. plt.imshow(image)
  27.  
  28. coord.request_stop()
  29. coord.join(thread)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement