  class Train():
      """ The training process.  """
      def __init__(self, arguments):
          logger.debug("Initializing %s: (args: %s", self.__class__.__name__, arguments)
          self.args = arguments
          self.timelapse = self.set_timelapse()
          self.images = self.get_images()
          self.stop = False
          self.save_now = False
          self.preview_buffer = dict()
          self.lock = Lock()
  
          self.trainer_name = self.args.trainer
          logger.debug("Initialized %s", self.__class__.__name__)
  
      def set_timelapse(self):
          """ Set time-lapse paths if requested """
          if (not self.args.timelapse_input_a and
 
</s> remove     """ The training process.  """
 </s> add     """ The Faceswap Training Process.

    The training process is responsible for training a model on a set of source faces and a set of
    destination faces.

    The training process is self contained and should not be referenced by any other scripts, so it
    contains no public properties.

    Parameters
    ----------
    arguments: argparse.Namespace
        The arguments to be passed to the training process as generated from Faceswap's command
        line arguments
    """ </s> remove     def set_timelapse(self):
        """ Set time-lapse paths if requested """
        if (not self.args.timelapse_input_a and
                not self.args.timelapse_input_b and
                not self.args.timelapse_output):
 </s> add     @property
    def _image_size(self):
        """ int: The training image size. Reads the first image in the training folder and returns
        the size. """
        image = read_image(self._images["a"][0], raise_error=True)
        size = image.shape[0]
        logger.debug("Training image size: %s", size)
        return size

    @property
    def _alignments_paths(self):
        """ dict: The alignments paths for each of the source and destination faces. Key is the
            side, value is the path to the alignments file """
        alignments_paths = dict()
        for side in ("a", "b"):
            alignments_path = getattr(self._args, "alignments_path_{}".format(side))
            if not alignments_path:
                image_path = getattr(self._args, "input_{}".format(side))
                alignments_path = os.path.join(image_path, "alignments.fsa")
            alignments_paths[side] = alignments_path
        logger.debug("Alignments paths: %s", alignments_paths)
        return alignments_paths

    def _set_timelapse(self):
        """ Set time-lapse paths if requested.

        Returns
        -------
        dict
            The time-lapse keyword arguments for passing to the trainer

        """
        if (not self._args.timelapse_input_a and
                not self._args.timelapse_input_b and
                not self._args.timelapse_output): </s> remove         self.model = model
        self.use_mask = use_mask
 </s> add         self._model = model
        self._use_mask = use_mask </s> remove class Landmarks():
    """ Set Landmarks for training into the model's training options"""
    def __init__(self, training_opts):
        logger.debug("Initializing %s: (training_opts: '%s')",
                     self.__class__.__name__, training_opts)
        self.size = training_opts.get("training_size", 256)
        self.paths = training_opts["alignments"]
        self.landmarks = self.get_alignments()
        logger.debug("Initialized %s", self.__class__.__name__)
 </s> add     @property
    def masks(self):
        """ dict: The :class:`lib.faces_detect.Mask` objects of requested mask type for
        keys a" and "b"
        """
        retval = {side: self._get_masks(side, detected_faces)
                  for side, detected_faces in self._detected_faces.items()}
        logger.trace(retval)
        return retval </s> remove         self.stop = True
 </s> add         self._stop = True
        self._args = arguments
        self._timelapse = self._set_timelapse()
        self._images = self._get_images()
        self._stop = False
        self._save_now = False
        self._preview_buffer = dict()
        self._lock = Lock()

        self.trainer_name = self._args.trainer
  class Train():
      """ The training process.  """
      def __init__(self, arguments):
          logger.debug("Initializing %s: (args: %s", self.__class__.__name__, arguments)
        self._args = arguments
        self._timelapse = self._set_timelapse()
        self._images = self._get_images()
        self._stop = False
        self._save_now = False
        self._preview_buffer = dict()
        self._lock = Lock()

        self.trainer_name = self._args.trainer
        self._args = arguments
        self._timelapse = self._set_timelapse()
        self._images = self._get_images()
        self._stop = False
        self._save_now = False
        self._preview_buffer = dict()
        self._lock = Lock()

        self.trainer_name = self._args.trainer
        self._args = arguments
        self._timelapse = self._set_timelapse()
        self._images = self._get_images()
        self._stop = False
        self._save_now = False
        self._preview_buffer = dict()
        self._lock = Lock()

        self.trainer_name = self._args.trainer
        self._args = arguments
        self._timelapse = self._set_timelapse()
        self._images = self._get_images()
        self._stop = False
        self._save_now = False
        self._preview_buffer = dict()
        self._lock = Lock()

        self.trainer_name = self._args.trainer
        self._args = arguments
        self._timelapse = self._set_timelapse()
        self._images = self._get_images()
        self._stop = False
        self._save_now = False
        self._preview_buffer = dict()
        self._lock = Lock()

        self.trainer_name = self._args.trainer
        self._args = arguments
        self._timelapse = self._set_timelapse()
        self._images = self._get_images()
        self._stop = False
        self._save_now = False
        self._preview_buffer = dict()
        self._lock = Lock()

        self.trainer_name = self._args.trainer
        self._args = arguments
        self._timelapse = self._set_timelapse()
        self._images = self._get_images()
        self._stop = False
        self._save_now = False
        self._preview_buffer = dict()
        self._lock = Lock()

        self.trainer_name = self._args.trainer
        self._args = arguments
        self._timelapse = self._set_timelapse()
        self._images = self._get_images()
        self._stop = False
        self._save_now = False
        self._preview_buffer = dict()
        self._lock = Lock()

        self.trainer_name = self._args.trainer
        self._args = arguments
        self._timelapse = self._set_timelapse()
        self._images = self._get_images()
        self._stop = False
        self._save_now = False
        self._preview_buffer = dict()
        self._lock = Lock()

        self.trainer_name = self._args.trainer
          logger.debug("Initialized %s", self.__class__.__name__)
  
      def set_timelapse(self):
          """ Set time-lapse paths if requested """
          if (not self.args.timelapse_input_a and
keep keep keep keep replace replace replace replace 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. 
scripts/train.py