Advertisement
Guest User

Untitled

a guest
Aug 20th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. # 1. Import TensorFlow.
  2. import tensorflow as tf
  3.  
  4. # 2. Declare filepaths of our images on disk.
  5. filenames = ['./images/img1.jpg', './images/img2.jpg']
  6. filename_queue = tf.train.string_input_producer(filenames, shuffle=False)
  7.  
  8. # 3. Read images from disk.
  9. reader = tf.WholeFileReader()
  10. key, value = reader.read(filename_queue)
  11.  
  12. # 4. Convert image to tensor
  13. image_queue = tf.image.decode_jpeg(value, channels=3) # use decode_png for .png files
  14.  
  15. # 5. List for storing our image tensors.
  16. images = []
  17.  
  18. with tf.Session():
  19. # 6. Start populating the filename queue.
  20. coord = tf.train.Coordinator()
  21. threads = tf.train.start_queue_runners(coord=coord)
  22.  
  23. # 7. Perform image decode operation.
  24. for _ in range(len(filenames)):
  25. images.append(image_queue.eval())
  26.  
  27. # 8. Stop queue runners.
  28. coord.request_stop()
  29. coord.join(threads)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement