title: OSError: cannot identify image file 'dataSet/.DS_Store'
body: <p>I am trying to run a facial recognition trainer that looks at a folder of jpg images of faces</p>
  <pre><code>import os                                               # importing the OS for path
  import cv2                                              # importing the OpenCV library
  import numpy as np                                      # importing Numpy library
  from PIL import Image                                   # importing Image library
  
  EigenFace = cv2.face.EigenFaceRecognizer_create(15)      # creating EIGEN FACE RECOGNISER
  FisherFace = cv2.face.FisherFaceRecognizer_create(2)     # Create FISHER FACE RECOGNISER
  LBPHFace = cv2.face.LBPHFaceRecognizer_create(1, 1, 7,7) # Create LBPH FACE RECOGNISER
  
  path = 'dataSet'                                        # path to the photos
  def getImageWithID (path):
      imagePaths = [os.path.join(path, f) for f in os.listdir(path)]
      FaceList = []
      IDs = []
      for imagePath in imagePaths:
          faceImage = Image.open(imagePath).convert('L')  # Open image and convert to gray
          faceImage = faceImage.resize((110,110))         # resize the image so the EIGEN recogniser can be trained
          faceNP = np.array(faceImage, 'uint8')           # convert the image to Numpy array
          ID = int(os.path.split(imagePath)[-1].split('.')[1])    # Retrieve the ID of the array
          FaceList.append(faceNP)                         # Append the Numpy Array to the list
          IDs.append(ID)                                  # Append the ID to the IDs list
          cv2.imshow('Training Set', faceNP)              # Show the images in the list
          cv2.waitKey(1)
      return np.array(IDs), FaceList                      # The IDs are converted in to a Numpy array
  IDs, FaceList = getImageWithID(path)
  </code></pre>
  <p>which in turn returns the error</p>
  <pre><code>Traceback (most recent call last):
    File &quot;/Users/jef/PycharmProjects/testProject/Python/Trainer_All.py&quot;, line 28, in &lt;module&gt;
      IDs, FaceList = getImageWithID(path)
    File &quot;/Users/jef/PycharmProjects/testProject/Python/Trainer_All.py&quot;, line 19, in getImageWithID
      faceImage = Image.open(imagePath).convert('L')  # Open image and convert to gray
    File &quot;/Users/jef/venv1/lib/python3.6/site-packages/PIL/Image.py&quot;, line 2452, in open
      % (filename if filename else fp))
  OSError: cannot identify image file 'dataSet/.DS_Store'
  </code></pre>
  <p>The folder dataSet exists and i'm running the code on my mac, and the most recent versions of Pillow, numpy and cv2, I've googled the OSError but not much came up to help this particular problem. Any ideas?</p>