              mask = mask.copy()
          if self._threshold != 0.0:
              mask[mask < self._threshold] = 0.0
              mask[mask > 255.0 - self._threshold] = 255.0
          if self._blur_kernel != 0:
              mask = cv2.GaussianBlur(mask, (self._blur_kernel, self._blur_kernel), 0)[..., None]
          logger.trace("mask shape: %s", mask.shape)
          return mask
  
      def get_full_frame_mask(self, width, height):
          """ Return the stored mask in a full size frame of the given dimensions
 
</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         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             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 not self.skip and self.do_erode:
            mask = self.erode(mask)
        if not self.skip and self.do_blend:
            mask = self.blend(mask)
 </s> add         if not self.skip and self._do_erode:
            mask = self._erode(mask)
        if self._blur["kernel"] != 0:
            mask = BlurMask(self._blur["type"],
                            mask,
                            self._blur["kernel"],
                            passes=self._blur["passes"]).blurred
              mask = mask.copy()
          if self._threshold != 0.0:
              mask[mask < self._threshold] = 0.0
              mask[mask > 255.0 - self._threshold] = 255.0
        if self._blur["kernel"] != 0:
            mask = BlurMask(self._blur["type"],
                            mask,
                            self._blur["kernel"],
                            passes=self._blur["passes"]).blurred
        if self._blur["kernel"] != 0:
            mask = BlurMask(self._blur["type"],
                            mask,
                            self._blur["kernel"],
                            passes=self._blur["passes"]).blurred
          logger.trace("mask shape: %s", mask.shape)
          return mask
  
      def get_full_frame_mask(self, width, height):
          """ Return the stored mask in a full size frame of the given dimensions
keep keep keep keep 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 
lib/faces_detect.py