                - The mask only
                - The masked face
          """
          mask = detected_face.mask[self._mask_type]
          mask.set_blur_kernel_and_threshold(**self._output_opts)
          if not self._output_full_frame or self._input_is_faces:
              if self._input_is_faces:
                  face = detected_face.image
              else:
                  detected_face.load_aligned(detected_face.image)
 
</s> remove     """ Filter in or out faces based on input image(s)
        Extract or Convert """
 </s> add     """ Filter in or out faces based on input image(s). Extract or Convert

    Parameters
    -----------
    args: tuple
        Unused
    kwargs: dict
        Keyword arguments for face filter:

        * **detector** (`str`) - The detector to use

        * **aligner** (`str`) - The aligner to use

        * **multiprocess** (`bool`) - Whether to run the extraction pipeline in single process \
        mode or not

        * **ref_threshold** (`float`) - The reference threshold for a positive match

        * **filter_lists** (`dict`) - The filter and nfilter image paths
    """ </s> remove             landmarks = detected_face.reference_landmarks
            mask = getattr(model_masks, self.mask_type)(landmarks, self.dummy, channels=1).mask
        np.nan_to_num(mask, copy=False)
        np.clip(mask, 0.0, 1.0, out=mask)
 </s> add             mask = detected_face.mask[self.mask_type]
            mask.set_blur_and_threshold(blur_kernel=self.config["kernel_size"],
                                        blur_type=self.config["type"],
                                        blur_passes=self.config["passes"],
                                        threshold=self.config["threshold"])
            mask = self._crop_to_coverage(mask.mask)

            mask_size = mask.shape[0]
            face_size = self.dummy.shape[0]
            if mask_size != face_size:
                interp = cv2.INTER_CUBIC if mask_size < face_size else cv2.INTER_AREA
                mask = cv2.resize(mask,
                                  self.dummy.shape[:2],
                                  interpolation=interp)[..., None]
        logger.trace(mask.shape)
        return mask

    def _crop_to_coverage(self, mask):
        """ Crop the mask to the correct dimensions based on coverage ratio.

        Parameters
        ----------
        mask: :class:`numpy.ndarray`
            The original mask to be cropped

        Returns
        -------
        :class:`numpy.ndarray`
            The cropped mask
        """
        if self._coverage_ratio == 1.0:
            return mask
        mask_size = mask.shape[0]
        padding = round((mask_size * (1 - self._coverage_ratio)) / 2)
        mask_slice = slice(padding, mask_size - padding)
        mask = mask[mask_slice, mask_slice, :]
        logger.trace("mask_size: %s, coverage: %s, padding: %s, final shape: %s",
                     mask_size, self._coverage_ratio, padding, mask.shape) </s> remove         if self.draw_transparent:
 </s> add         if self._draw_transparent: </s> remove         if self._threshold != 0.0 or self._blur_kernel != 0:
 </s> add         if self._threshold != 0.0 or self._blur["kernel"] != 0: </s> remove     def get_image_mask(self, new_face, detected_face, predicted_mask):
        """ Get the image mask """
 </s> add     def _get_image_mask(self, new_face, detected_face, predicted_mask):
        """ Return any selected image mask and intersect with any box mask.

        Places the requested mask into the new face's Alpha channel, intersecting with any box
        mask that has already been applied.

        Parameters
        ----------
        new_face: :class:`numpy.ndarray`
            The swapped face received from the faceswap model, with any box mask applied
        detected_face: :class:`~lib.faces_detect.DetectedFace`
            The detected_face object as defined in :class:`scripts.convert.Predictor`
        predicted_mask: :class:`numpy.ndarray` or ``None``
            The predicted mask output from the Faceswap model. ``None`` if the model
            did not learn a mask

        Returns
        :class:`numpy.ndarray`
            The swapped face with the requested mask added to the Alpha channel
        """
        mask.set_blur_and_threshold(**self._output_opts)
                - The mask only
                - The masked face
          """
          mask = detected_face.mask[self._mask_type]
        mask.set_blur_and_threshold(**self._output_opts)
          if not self._output_full_frame or self._input_is_faces:
              if self._input_is_faces:
                  face = detected_face.image
              else:
                  detected_face.load_aligned(detected_face.image)
keep keep keep keep 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 
tools/mask.py