<filename>model/utils/tensorflow_image_data.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
Example script to read jpeg images in the tensorflow (create a separate class)
Created on Fri May 11 12:04:34 2018
@author: jehill
"""

import tensorflow as tf

filename_queue = tf.train.string_input_producer(
tf.train.match_filenames_once("./tensorflow_check/*.tif"))

# Read an entire image file which is required since they're JPEGs, if the images
# are too large they could be split in advance to smaller files or use the Fixed
# reader to split up the file.
image_reader = tf.WholeFileReader()

# Read a whole file from the queue, the first returned value in the tuple is the
# filename which we are ignoring.
_, image_file = image_reader.read(filename_queue)

# Decode the image as a JPEG file, this will turn it into a Tensor which we can
# then use in training.
image = tf.image.decode_jpeg(image_file)

# Start a new session to show example output.
with tf.Session() as sess:
    # Required to get the filename matching to run.
    tf.global_variables_initializer()

    # Coordinate the loading of image files.
    coord = tf.train.Coordinator()
    threads = tf.train.start_queue_runners(coord=coord)

    # Get an image tensor and print its value.
    image_tensor = sess.run([image])
    print(image_tensor)

    # Finish off the filename queue coordinator.
    coord.request_stop()
    coord.join(threads)
<filename>model/utils/tensorflow_image_data.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
Example script to read jpeg images in the tensorflow (create a separate class)
Created on Fri May 11 12:04:34 2018
@author: jehill
"""

import tensorflow as tf

filename_queue = tf.train.string_input_producer(
tf.train.match_filenames_once("./tensorflow_check/*.tif"))

# Read an entire image file which is required since they're JPEGs, if the images
# are too large they could be split in advance to smaller files or use the Fixed
# reader to split up the file.
image_reader = tf.WholeFileReader()

# Read a whole file from the queue, the first returned value in the tuple is the
# filename which we are ignoring.
_, image_file = image_reader.read(filename_queue)

# Decode the image as a JPEG file, this will turn it into a Tensor which we can
# then use in training.
image = tf.image.decode_jpeg(image_file)

# Start a new session to show example output.
with tf.Session() as sess:
    # Required to get the filename matching to run.
    tf.global_variables_initializer()

    # Coordinate the loading of image files.
    coord = tf.train.Coordinator()
    threads = tf.train.start_queue_runners(coord=coord)

    # Get an image tensor and print its value.
    image_tensor = sess.run([image])
    print(image_tensor)

    # Finish off the filename queue coordinator.
    coord.request_stop()
    coord.join(threads)
#!/usr/bin/env python3 # -*- coding: utf-8 -*- Example script to read jpeg images in the tensorflow (create a separate class) Created on Fri May 11 12:04:34 2018 @author: jehill # Read an entire image file which is required since they're JPEGs, if the images # are too large they could be split in advance to smaller files or use the Fixed # reader to split up the file. # Read a whole file from the queue, the first returned value in the tuple is the # filename which we are ignoring. # Decode the image as a JPEG file, this will turn it into a Tensor which we can # then use in training. # Start a new session to show example output. # Required to get the filename matching to run. # Coordinate the loading of image files. # Get an image tensor and print its value. # Finish off the filename queue coordinator.