title: Load image files in a directory as dataset for training in Tensorflow
body: <p>I am a newbie for tensorflow, and I'm starting with the offical MNIST example code to learn the logic of tensorflow. However, one thing I felt not good is that, the MNIST example provides the original dataset as some compressed files, whose format is not clear to beginners. This case also goes with Cifar10 which provides the dataset as a binary file. I think in practical deep learning task, our dataset may be lots of image files, such as <code>*.jpg</code> or <code>*.png</code> in a directory, and we also have a text file recording the label of each file (like ImageNet dataset). Let me use MNIST as an example.</p>
  
  <p>MNIST contains 50k training images of size <code>28 x 28</code>. Now let's assume these images are in jpg format, and stored in a directory <code>./dataset/</code>. In <code>./dataset/</code>, we have a text file <code>label.txt</code> storing the label of each image:</p>
  
  <pre><code>/path/to/dataset/
                   image00001.jpg
                   image00002.jpg
                   ... ... ... ...
                   image50000.jpg
                   label.txt
  </code></pre>
  
  <p>where <code>label.txt</code> is like this:</p>
  
  <pre><code>#label.txt:
  image00001.jpg 1
  image00002.jpg 0
  image00003.jpg 4
  image00004.jpg 9
  ... ... ... ... 
  image50000.jpg 3
  </code></pre>
  
  <p>Now I would like to use Tensorflow to train a single layer model with these dataset. Could anyone help to give a simple code snippet to do that?</p>