      def process_face(self, filename, side, is_timelapse):
          """ Load an image and perform transformation and warping """
          logger.trace("Process face: (filename: '%s', side: '%s', is_timelapse: %s)",
                       filename, side, is_timelapse)
          try:
              image = cv2.imread(filename)  # pylint: disable=no-member
          except TypeError:
              raise Exception("Error while reading image", filename)
  
          if self.mask_class or self.training_opts["warp_to_landmarks"]:
              src_pts = self.get_landmarks(filename, image, side)
          if self.mask_class:
              image = self.mask_class(src_pts, image, channels=4).mask
  
 
</s> remove             logger.trace("Loading image: '%s'", filename)
            try:
                image = cv2.imread(filename)  # pylint: disable=no-member
            except Exception as err:  # pylint: disable=broad-except
                logger.error("Failed to load image '%s'. Original Error: %s", filename, err)
 </s> add             image = cv2_read_img(filename, raise_error=False)
            if image is None: </s> remove     img = cv2.imread(filename)  # pylint: disable=no-member
 </s> add     img = cv2_read_img(filename, raise_error=True) </s> remove             image = cv2.imread(src)  # pylint: disable=no-member
 </s> add             image = cv2_read_img(src, raise_error=True) </s> remove         Estimate the amount of blur an image has
        with the variance of the Laplacian.
        Normalize by pixel number to offset the effect
        of image size on pixel gradients & variance
 </s> add         Estimate the amount of blur an image has with the variance of the Laplacian.
        Normalize by pixel number to offset the effect of image size on pixel gradients & variance </s> remove             retval = cv2.imread(filename)  # pylint: disable=no-member
 </s> add             retval = cv2_read_img(filename, raise_error=True)
        image = cv2_read_img(filename, raise_error=True)
      def process_face(self, filename, side, is_timelapse):
          """ Load an image and perform transformation and warping """
          logger.trace("Process face: (filename: '%s', side: '%s', is_timelapse: %s)",
                       filename, side, is_timelapse)
        image = cv2_read_img(filename, raise_error=True)
        image = cv2_read_img(filename, raise_error=True)
        image = cv2_read_img(filename, raise_error=True)
        image = cv2_read_img(filename, raise_error=True)
        image = cv2_read_img(filename, raise_error=True)
          if self.mask_class or self.training_opts["warp_to_landmarks"]:
              src_pts = self.get_landmarks(filename, image, side)
          if self.mask_class:
              image = self.mask_class(src_pts, image, channels=4).mask
  
keep keep keep keep replace replace replace replace replace keep keep keep keep keep
 Centralize cv2 image reading and handle bad filenames 
lib/training_data.py