title: How to load images from memory to numpy using file system
body: <p>I want to store my image directory in memory, then load the images into a numpy array.</p>
  <p>The normative way to load images that <strong>are not in memory</strong> is as follows:</p>
  <pre><code>import PIL.Image
  import numpy as np
  
  image = PIL.Image.open(&quot;./image_dir/my_image_1.jpg&quot;)
  image = np.array(image)
  </code></pre>
  <p>However, I am not sure how to do this when the images <strong>are in memory</strong>. So far, I have been able to setup the following starter code:</p>
  <pre><code>import fs
  import fs.memoryfs
  import fs.osfs
  
  image_dir = &quot;./image_dir&quot;
  
  mem_fs = fs.memoryfs.MemoryFS()
  drv_fs = fs.osfs.OSFS(image_path)
  
  fs.copy.copy_fs(drv_fs, mem_fs)
  
  print(mem_fs.listdir('.'))
  </code></pre>
  <p>Returns:</p>
  <pre><code>['my_image_1.jpg', 'my_image_2.jpg']
  </code></pre>
  <p>How do I load images that <strong>are in memory</strong> into numpy?</p>
  <p>I am also open to alternatives to the fs package.</p>