title: How to create a TFRecord from a NumPy array
body: <p>I'd like to 1. iterate through a directory of images and turn each image into a NumPy array. I think I have accomplished this with the following code:</p>
  
  <pre><code>import tensorflow as tf
  import matplotlib
  matplotlib.use('TkAgg')
  import matplotlib.pyplot as plt
  import matplotlib.image as mpimg
  import numpy as np
  from PIL import Image
  import os
  
  myimages = []
  
  path_to_images = 'images_animation'
  filenum = len([name for name in os.listdir(path_to_images) if os.path.isfile(os.path.join(path_to_images, name))])
  
  #loops through available pngs
  for p in range(1, filenum):
  
      ## Read in picture
      fname = "images_animation/image%03d.png" % p
      img = mpimg.imread(fname)
      imgplot = plt.imshow(img)
  
      # append AxesImage object to the list
      myimages.append([imgplot])
  
  for n, im in enumerate(myimages):
      img = Image.open(fname).convert("L")
      arr = np.array(img
      print(arr)
  </code></pre>
  
  <p>If I can make this code better or more efficient, please feel free to tell me how.</p>
  
  <p>Now, I'd like to 2. turn these NumPy arrays into TFRecords. What is the best way to do so? I'm near clueless as how to do this, so I have not done much to solve it myself, so I'm looking for a solution.</p>