Loading Images in a Directory As Tensorflow Data set
<p>I'm relatively new to ML and very much new to TensorfFlow. I've spent quite a bit of time on the TensorFlow MINST tutorial as well as <a href="https://github.com/tensorflow/tensorflow/tree/master/tensorflow/examples/how_tos/reading_data" rel="noreferrer">https://github.com/tensorflow/tensorflow/tree/master/tensorflow/examples/how_tos/reading_data</a> to try and figure out how to read my own data, but I'm getting a bit confused.</p>

<p>I have a bunch of images (.png) in a directory /images/0_Non/. I'm trying to make these into a TensorFlow Data set so then I can basically run the stuff from the MINST tutorial on it as a first pass.</p>

<pre><code>import tensorflow as tf

# Make a queue of file names including all the JPEG images files in the relative image directory.
filename_queue = tf.train.string_input_producer(tf.train.match_filenames_once("../images/0_Non/*.png"))

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)

image = tf.image.decode_png(image_file)

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

    # 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)
</code></pre>

<p>I'm having a bit of trouble understanding what's going on here. So it seems like <code>image</code> is a tensor and <code>image_tensor</code> is an numpy array? </p>

<p>How do I get my images into a data set? I also tried following along the Iris example which is for a CSV which brought me to here: <a href="https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/learn/python/learn/datasets/base.py" rel="noreferrer">https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/learn/python/learn/datasets/base.py</a>, but wasn't sure how to get this to work for my case where I have a bunch of png's.</p>

<p>Thanks!</p>