      def process(self, detected_face, predicted_mask=None):
          """ Return mask and perform processing """
          mask = self.get_mask(detected_face, predicted_mask)
          raw_mask = mask.copy()
          if not self.skip and self.do_erode:
              mask = self.erode(mask)
          if not self.skip and self.do_blend:
              mask = self.blend(mask)
          raw_mask = np.expand_dims(raw_mask, axis=-1) if raw_mask.ndim != 3 else raw_mask
          mask = np.expand_dims(mask, axis=-1) if mask.ndim != 3 else mask
          logger.trace("mask shape: %s, raw_mask shape: %s", mask.shape, raw_mask.shape)
          return mask, raw_mask
  
 
</s> remove         return mask, raw_mask
 </s> add         return mask.astype("float32") / 255.0, raw_mask.astype("float32") / 255.0

    def _get_mask(self, detected_face, predicted_mask):
        """ Return the requested mask with any requested blurring applied. </s> remove     def get_mask(self, detected_face, predicted_mask):
        """ Return the mask from lib/model/masks and intersect with box """
 </s> add         Parameters
        ----------
        detected_face: :class:`lib.faces_detect.DetectedFace`
            The DetectedFace object as returned from :class:`scripts.convert.Predictor`.
        predicted_mask: :class:`numpy.ndarray`
            The predicted mask as output from the Faceswap Model if the model was trained
            with a mask, otherwise ``None``

        Returns
        -------
        :class:`numpy.ndarray`
            The mask sized to Faceswap model output with any requested blurring applied.
        """ </s> remove     """ Return the requested mask """
    def __init__(self, mask_type, output_size, predicted_available, **kwargs):
        super().__init__(mask_type, output_size, predicted_available, **kwargs)
        self.do_erode = self.config.get("erosion", 0) != 0
        self.do_blend = self.config.get("type", None) is not None

    def process(self, detected_face, predicted_mask=None):
        """ Return mask and perform processing """
        mask = self.get_mask(detected_face, predicted_mask)
 </s> add     """ Manipulations to perform to the mask that is to be applied to the output of the Faceswap
    model.

    Parameters
    ----------
    mask_type: str
        The mask type to use for this plugin
    output_size: int
        The size of the output from the Faceswap model.
    coverage_ratio: float
        The coverage ratio that the Faceswap model was trained at.
    **kwargs: dict, optional
        See the parent :class:`~plugins.convert.mask._base` for additional keyword arguments.
    """
    def __init__(self, mask_type, output_size, coverage_ratio, **kwargs):
        super().__init__(mask_type, output_size, **kwargs)
        self._do_erode = self.config.get("erosion", 0) != 0
        self._coverage_ratio = coverage_ratio

    def process(self, detected_face, predicted_mask=None):  # pylint:disable=arguments-differ
        """ Obtain the requested mask type and perform any defined mask manipulations.

        Parameters
        ----------
        detected_face: :class:`lib.faces_detect.DetectedFace`
            The DetectedFace object as returned from :class:`scripts.convert.Predictor`.
        predicted_mask: :class:`numpy.ndarray`, optional
            The predicted mask as output from the Faceswap Model, if the model was trained
            with a mask, otherwise ``None``. Default: ``None``.

        Returns
        -------
        mask: :class:`numpy.ndarray`
            The mask with all requested manipulations applied
        raw_mask: :class:`numpy.ndarray`
            The mask with no erosion/dilation applied
        """
        mask = self._get_mask(detected_face, predicted_mask) </s> remove         mask, raw_mask = self.adjustments["mask"].run(detected_face, predicted_mask)
 </s> add         mask, raw_mask = self._adjustments["mask"].run(detected_face, predicted_mask) </s> remove         new_face = self.adjustments["box"].run(new_face)
        new_face, raw_mask = self.get_image_mask(new_face, detected_face, predicted_mask)
        if self.adjustments["color"] is not None:
            new_face = self.adjustments["color"].run(old_face, new_face, raw_mask)
        if self.adjustments["seamless"] is not None:
            new_face = self.adjustments["seamless"].run(old_face, new_face, raw_mask)
 </s> add         old_face = detected_face.reference_face[..., :3] / 255.0
        new_face = self._adjustments["box"].run(new_face)
        new_face, raw_mask = self._get_image_mask(new_face, detected_face, predicted_mask)
        if self._adjustments["color"] is not None:
            new_face = self._adjustments["color"].run(old_face, new_face, raw_mask)
        if self._adjustments["seamless"] is not None:
            new_face = self._adjustments["seamless"].run(old_face, new_face, raw_mask)
        if not self.skip and self._do_erode:
            mask = self._erode(mask)
      def process(self, detected_face, predicted_mask=None):
          """ Return mask and perform processing """
          mask = self.get_mask(detected_face, predicted_mask)
          raw_mask = mask.copy()
        if not self.skip and self._do_erode:
            mask = self._erode(mask)
        if not self.skip and self._do_erode:
            mask = self._erode(mask)
        if not self.skip and self._do_erode:
            mask = self._erode(mask)
        if not self.skip and self._do_erode:
            mask = self._erode(mask)
          raw_mask = np.expand_dims(raw_mask, axis=-1) if raw_mask.ndim != 3 else raw_mask
          mask = np.expand_dims(mask, axis=-1) if mask.ndim != 3 else mask
          logger.trace("mask shape: %s, raw_mask shape: %s", mask.shape, raw_mask.shape)
          return mask, raw_mask
  
keep keep keep keep replace replace replace replace keep keep keep keep keep
 Smart Masks to Convert (#957)

- scripts.convert - Use Smart Masks for Convert
    * Make on-the-fly conversion an explicit option

- Move BlurMask to lib.faces_detect

- tools.preview - Fix for smart masks
    * Subclass from tk.Tk
    * Options to lib.gui.control_helper
    *variable cleanup

- lib.logger - Demote more tensorflow deprecation messages

- Documentation:
    * lib.faces_detect.BlurMask
    * plugins.convert.mask
    * lib.convert
    * scripts.convert
    * scripts.fsmedia
    * tools.preview 
plugins/convert/mask/mask_blend.py