      """
      logger.trace("Requested batch: '%s'", filenames)
      executor = futures.ThreadPoolExecutor()
      with executor:
          images = [executor.submit(read_image, filename, raise_error=True)
                    for filename in filenames]
          batch = np.array([future.result() for future in futures.as_completed(images)])
      logger.trace("Returning images: %s", batch.shape)
      return batch
  
  
  def read_image_hash(filename):
      """ Return the `sha1` hash of an image saved on disk.
  
 
</s> remove     >>> images = read_image_batch(image_filenames)
 </s> add     >>> filenames, images = read_image_batch(image_filenames) </s> remove         src_points = [self._landmarks[side].get(sha1(face).hexdigest(), None) for face in batch]

 </s> add         src_points = [self._landmarks[side].get(filename, None) for filename in filenames] </s> remove         batch = read_image_batch(filenames)
 </s> add         filenames, batch = read_image_batch(filenames)
        batch = self._apply_mask(filenames, batch, side) </s> remove         to_landmarks = self._training_opts["warp_to_landmarks"]
 </s> add  </s> remove     def get_next(self, do_preview):
        """ Return the next batch from the generator
            Items should come out as: (warped, target [, mask]) """
        batch = next(self.feed)
        if self.use_mask:
            batch = [[batch["feed"], batch["masks"]], batch["targets"] + [batch["masks"]]]
        else:
            batch = [batch["feed"], batch["targets"]]
        self.generate_preview(do_preview)
        return batch
 </s> add     def _get_next(self):
        """ Return the next batch from the :class:`lib.training_data.TrainingDataGenerator` for
        this batcher ready for feeding into the model.

        Returns
        -------
        model_inputs: list
            A list of :class:`numpy.ndarray` for feeding into the model
        model_targets: list
            A list of :class:`numpy.ndarray` for comparing the output of the model
        """
        logger.trace("Generating targets")
        batch = next(self._feed)
        targets_use_mask = self._model.training_opts["learn_mask"]
        model_inputs = batch["feed"] + batch["masks"] if self._use_mask else batch["feed"]
        model_targets = batch["targets"] + batch["masks"] if targets_use_mask else batch["targets"]
        return model_inputs, model_targets
        images = {executor.submit(read_image, filename, raise_error=True): filename
                  for filename in filenames}
        batch = []
        filenames = []
        for future in futures.as_completed(images):
            batch.append(future.result())
            filenames.append(images[future])
        batch = np.array(batch)
    logger.trace("Returning images: (filenames: %s, batch shape: %s)", filenames, batch.shape)
    return filenames, batch
      """
      logger.trace("Requested batch: '%s'", filenames)
      executor = futures.ThreadPoolExecutor()
      with executor:
        images = {executor.submit(read_image, filename, raise_error=True): filename
                  for filename in filenames}
        batch = []
        filenames = []
        for future in futures.as_completed(images):
            batch.append(future.result())
            filenames.append(images[future])
        batch = np.array(batch)
    logger.trace("Returning images: (filenames: %s, batch shape: %s)", filenames, batch.shape)
    return filenames, batch
        images = {executor.submit(read_image, filename, raise_error=True): filename
                  for filename in filenames}
        batch = []
        filenames = []
        for future in futures.as_completed(images):
            batch.append(future.result())
            filenames.append(images[future])
        batch = np.array(batch)
    logger.trace("Returning images: (filenames: %s, batch shape: %s)", filenames, batch.shape)
    return filenames, batch
        images = {executor.submit(read_image, filename, raise_error=True): filename
                  for filename in filenames}
        batch = []
        filenames = []
        for future in futures.as_completed(images):
            batch.append(future.result())
            filenames.append(images[future])
        batch = np.array(batch)
    logger.trace("Returning images: (filenames: %s, batch shape: %s)", filenames, batch.shape)
    return filenames, batch
        images = {executor.submit(read_image, filename, raise_error=True): filename
                  for filename in filenames}
        batch = []
        filenames = []
        for future in futures.as_completed(images):
            batch.append(future.result())
            filenames.append(images[future])
        batch = np.array(batch)
    logger.trace("Returning images: (filenames: %s, batch shape: %s)", filenames, batch.shape)
    return filenames, batch
        images = {executor.submit(read_image, filename, raise_error=True): filename
                  for filename in filenames}
        batch = []
        filenames = []
        for future in futures.as_completed(images):
            batch.append(future.result())
            filenames.append(images[future])
        batch = np.array(batch)
    logger.trace("Returning images: (filenames: %s, batch shape: %s)", filenames, batch.shape)
    return filenames, batch
  
  
  def read_image_hash(filename):
      """ Return the `sha1` hash of an image saved on disk.
  
keep keep keep keep replace replace replace replace replace keep keep keep keep keep
 Smart Masks - Training Implementation (#914)

* Smart Masks - Training

- Reinstate smart mask training code
- Reinstate mask_type back to model.config
- change 'replicate_input_mask to 'learn_mask'
- Add learn mask option
- Add mask loading from alignments to plugins.train.trainer
- Add mask_blur and mask threshold options
- _base.py - Pass mask options through training_opts dict
- plugins.train.model - check for mask_type not None for learn_mask and penalized_mask_loss
- Limit alignments loading to just those faces that appear in the training folder
- Raise error if not all training images have an alignment, and alignment file is required
- lib.training_data - Mask generation code
- lib.faces_detect - cv2 dimension stripping bugfix
- Remove cv2 linting code

* Update mask helptext in cli.py

* Fix Warp to Landmarks
Remove SHA1 hashing from training data

* Update mask training config

* Capture missing masks at training init

* lib.image.read_image_batch - Return filenames with batch for ordering

* scripts.train - Documentation

* plugins.train.trainer - documentation

* Ensure backward compatibility.
Fix convert for new predicted masks

* Update removed masks to components for legacy models. 
lib/image.py