title: Tensorflow dataset API with ListDirectory
body: <p>I want to use the Tensorflow Dataset API to create one batch per folder (each folder containing images). I have the following simple code snippet:</p>
  
  <pre><code>import tensorflow as tf
  import os
  import pdb
  
  def parse_file(filename):
      image_string = tf.read_file(filename)
      image_decoded = tf.image.decode_png(image_string)
      image_resized = tf.image.resize_images(image_decoded, [48, 48])
      return image_resized #, label
  
  def parse_dir(frame_dir):
      filenames = tf.gfile.ListDirectory(frame_dir)
      batch = tf.constant(5)
      batch = tf.map_fn(parse_file, filenames)
      return batch
  
  directory = "../Detections/NAC20171125"
  # filenames = tf.constant([os.path.join(directory, f) for f in os.listdir(directory)])
  frames = [os.path.join(directory, str(f)) for f in range(10)]
  
  
  dataset = tf.data.Dataset.from_tensor_slices((frames))
  dataset = dataset.map(parse_dir)
  
  dataset = dataset.batch(256)
  iterator = dataset.make_initializable_iterator()
  next_element = iterator.get_next()
  
  
  with tf.Session() as sess:
      sess.run(iterator.initializer)
      while True:
          try:
              batch = sess.run(next_element)
              print(batch.shape)
          except tf.errors.OutOfRangeError:
              break
  </code></pre>
  
  <p>However, tf.gfile.ListDirectory (in parse_dir) expects a normal string instead of a Tensor. So now the error is </p>
  
  <pre><code>TypeError: Expected binary or unicode string, got &lt;tf.Tensor 'arg0:0' shape=() dtype=string&gt;
  </code></pre>
  
  <p>Is there a simple way to solve this?</p>