  
      def get_image_mask(self, new_face, detected_face, predicted_mask):
          """ Get the image mask """
          logger.trace("Getting mask. Image shape: %s", new_face.shape)
          mask, raw_mask = self.adjustments["mask"].run(detected_face, predicted_mask)
          if new_face.shape[2] == 4:
              logger.trace("Combining mask with alpha channel box mask")
              new_face[:, :, -1] = np.minimum(new_face[:, :, -1], mask.squeeze())
          else:
              logger.trace("Adding mask to alpha channel")
 
</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
        """ </s> remove         np.clip(new_face, 0.0, 1.0, out=new_face)
 </s> add  </s> remove             src_face = detected_face.reference_face[..., :3] / 255.0
 </s> add  </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) </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.
        mask, raw_mask = self._adjustments["mask"].run(detected_face, predicted_mask)
  
      def get_image_mask(self, new_face, detected_face, predicted_mask):
          """ Get the image mask """
          logger.trace("Getting mask. Image shape: %s", new_face.shape)
        mask, raw_mask = self._adjustments["mask"].run(detected_face, predicted_mask)
          if new_face.shape[2] == 4:
              logger.trace("Combining mask with alpha channel box mask")
              new_face[:, :, -1] = np.minimum(new_face[:, :, -1], mask.squeeze())
          else:
              logger.trace("Adding mask to alpha channel")
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 
lib/convert.py