Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 1. Import TensorFlow.
- import tensorflow as tf
- # 2. Declare filepaths of our images on disk.
- filenames = ['./images/img1.jpg', './images/img2.jpg']
- filename_queue = tf.train.string_input_producer(filenames, shuffle=False)
- # 3. Read images from disk.
- reader = tf.WholeFileReader()
- key, value = reader.read(filename_queue)
- # 4. Convert image to tensor
- image_queue = tf.image.decode_jpeg(value, channels=3) # use decode_png for .png files
- # 5. List for storing our image tensors.
- images = []
- with tf.Session():
- # 6. Start populating the filename queue.
- coord = tf.train.Coordinator()
- threads = tf.train.start_queue_runners(coord=coord)
- # 7. Perform image decode operation.
- for _ in range(len(filenames)):
- images.append(image_queue.eval())
- # 8. Stop queue runners.
- coord.request_stop()
- coord.join(threads)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement