title: Extract details in multiple image filenames in Python and add them as labels for a dataset
body: <p>I have a folder containing 1300 .JPEG files all of which have filenames in a specific order.</p>
  
  <p>The order of each file name is category_count_randomString.JPEG. To give an example, below is one image from the folder:</p>
  
  <p><code>13_2_5jdf.JPEG</code> where 13 is the category, 2 is the count of that category in the image, followed by the random string.</p>
  
  <p>I'd like to be able to:</p>
  
  <ol>
  <li>extract both the category from each filename and assign them as labels (to then build a CNN model) and</li>
  <li>extract the count of the category from each filename and also assign them to a vector/array.</li>
  </ol>
  
  <p>For now, I've just loaded the images (not yet as an array) using the glob function.</p>
  
  <pre><code>import glob
  
  data = '/Users/Data'
  
  images = glob.glob(data+'/*.JPEG')
  </code></pre>
  
  <p>I'm new to coding and so I'm looking for someone to be able to provide 'idiot-proof' lines of coding that I can just incorporate into my notebook to make this work.</p>