              batch = batch_convert_color(batch, "LAB2BGR")
          return batch
  
      def _random_clahe(self, batch):
          """ Randomly perform Contrast Limited Adaptive Histogram Equilization on
          a batch of images """
          base_contrast = self._constants["clahe_base_contrast"]
  
          batch_random = np.random.rand(self._batchsize)
          indices = np.where(batch_random > self._config.get("color_clahe_chance", 50) / 100)[0]
 
</s> remove         """ Perform random color/lightness adjustment in L*a*b* colorspace on a batch of images """
 </s> add         """ Perform random color/lightness adjustment in L*a*b* color space on a batch of
        images """ </s> remove         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
 </s> add         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 </s> remove     def train_one_batch(self, do_preview):
        """ Train a batch """
        logger.trace("Training one step: (side: %s)", self.side)
        batch = self.get_next(do_preview)
 </s> add     def train_one_batch(self):
        """ Train on a single batch of images for this :class:`Batcher`

        Returns
        -------
        list
            The list of loss values (as ``float``) for this batch
        """
        logger.trace("Training one step: (side: %s)", self._side)
        model_inputs, model_targets = self._get_next() </s> remove         """ Timelapse samples """
        batch = next(self.timelapse_feed)
 </s> add         """ Compile the sample images for creating a time-lapse frame.

        Returns
        -------
        list
            The list of samples, targets and masks as :class:`numpy.ndarrays` for creating a
            time-lapse frame
        """
        batch = next(self._timelapse_feed) </s> remove         batch = read_image_batch(filenames)
 </s> add         filenames, batch = read_image_batch(filenames)
        batch = self._apply_mask(filenames, batch, side)
        """ Randomly perform Contrast Limited Adaptive Histogram Equalization on
              batch = batch_convert_color(batch, "LAB2BGR")
          return batch
  
      def _random_clahe(self, batch):
        """ Randomly perform Contrast Limited Adaptive Histogram Equalization on
          a batch of images """
          base_contrast = self._constants["clahe_base_contrast"]
  
          batch_random = np.random.rand(self._batchsize)
          indices = np.where(batch_random > self._config.get("color_clahe_chance", 50) / 100)[0]
keep keep keep keep 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/training_data.py