          """ Generate the preview and write preview file output """
          logger.trace("Updating preview: (name: %s)", name)
          try:
              scriptpath = os.path.realpath(os.path.dirname(sys.argv[0]))
              if self.args.write_image:
                  logger.trace("Saving preview to disk")
                  img = "training_preview.jpg"
                  imgfile = os.path.join(scriptpath, img)
                  cv2.imwrite(imgfile, image)  # pylint: disable=no-member
                  logger.trace("Saved preview to: '%s'", img)
 
</s> remove             if self.args.redirect_gui:
 </s> add             if self._args.redirect_gui: </s> remove     def show(self, image, name=""):
        """ Generate the preview and write preview file output """
 </s> add     def _show(self, image, name=""):
        """ Generate the preview and write preview file output.

        Handles the output and display of preview images.

        Parameters
        ----------
        image: :class:`numpy.ndarray`
            The preview image to be displayed and/or written out
        name: str, optional
            The name of the image for saving or display purposes. If an empty string is passed
            then it will automatically be names. Default: ""
        """ </s> remove             if self.args.preview:
 </s> add             if self._args.preview: </s> remove                 with self.lock:
                    self.preview_buffer[name] = image
 </s> add                 with self._lock:
                    self._preview_buffer[name] = image </s> remove             self.samples = None
            self.target = None
 </s> add             self._samples = None
            self._target = None
            self._masks = None
            if self._args.write_image:
          """ Generate the preview and write preview file output """
          logger.trace("Updating preview: (name: %s)", name)
          try:
              scriptpath = os.path.realpath(os.path.dirname(sys.argv[0]))
            if self._args.write_image:
                  logger.trace("Saving preview to disk")
                  img = "training_preview.jpg"
                  imgfile = os.path.join(scriptpath, img)
                  cv2.imwrite(imgfile, image)  # pylint: disable=no-member
                  logger.trace("Saved preview to: '%s'", img)
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. 
scripts/train.py