              patched_face = self.writer_pre_encode(patched_face)
          logger.trace("Patched image: '%s'", predicted["filename"])
          return patched_face
  
      def get_new_image(self, predicted, frame_size):
          """ Get the new face from the predictor and apply box manipulations """
          logger.trace("Getting: (filename: '%s', faces: %s)",
                       predicted["filename"], len(predicted["swapped_faces"]))
  
          placeholder = np.zeros((frame_size[1], frame_size[0], 4), dtype="float32")
          background = predicted["image"] / np.array(255.0, dtype="float32")
 
</s> remove         patched_face = np.rint(
            patched_face,
            out=np.empty(patched_face.shape, dtype="uint8"),
            casting='unsafe'
        )
        if self.writer_pre_encode is not None:
            patched_face = self.writer_pre_encode(patched_face)
 </s> add         patched_face = np.rint(patched_face,
                               out=np.empty(patched_face.shape, dtype="uint8"),
                               casting='unsafe')
        if self._writer_pre_encode is not None:
            patched_face = self._writer_pre_encode(patched_face) </s> remove         new_image, background = self.get_new_image(predicted, frame_size)
        patched_face = self.post_warp_adjustments(background, new_image)
        patched_face = self.scale_image(patched_face)
 </s> add         new_image, background = self._get_new_image(predicted, frame_size)
        patched_face = self._post_warp_adjustments(background, new_image)
        patched_face = self._scale_image(patched_face) </s> remove     def patch_image(self, predicted):
        """ Patch the image """
 </s> add     def _patch_image(self, predicted):
        """ Patch a swapped face onto a frame.

        Run selected adjustments and swap the faces in a frame.

        Parameters
        ----------
        predicted: dict
            The output from :class:`scripts.convert.Predictor`.

        Returns
        -------
        :class: `numpy.ndarray` or pre-encoded image output
            The final frame ready for writing by a :mod:`plugins.convert.writer` plugin.
            Frame is either an array, or the pre-encoded output from the writer's pre-encode
            function (if it has one)

        """ </s> remove     def has_predicted_mask(self):
        """ Return whether this model has a predicted mask """
        return bool(self.model.state.config.get("learn_mask", False))
 </s> add     def _input_mask(self):
        """ :class:`numpy.ndarray`: A dummy mask for inputting to the model. """
        mask = np.zeros((1, ) + self._model.state.mask_shapes[0], dtype="float32")
        return mask </s> remove         faces = self.alignments.get_faces_in_frame(frame)
 </s> add         faces = self._alignments.get_faces_in_frame(frame_name)
    def _get_new_image(self, predicted, frame_size):
        """ Get the new face from the predictor and apply pre-warp manipulations.

        Applies any requested adjustments to the raw output of the Faceswap model
        before transforming the image into the target frame.

        Parameters
        ----------
        predicted: dict
            The output from :class:`scripts.convert.Predictor`.
        frame_size: tuple
            The (`width`, `height`) of the final frame in pixels

        Returns
        -------
        placeholder:  :class: `numpy.ndarray`
            The original frame with the swapped faces patched onto it
        background:  :class: `numpy.ndarray`
            The original frame
        """
              patched_face = self.writer_pre_encode(patched_face)
          logger.trace("Patched image: '%s'", predicted["filename"])
          return patched_face
  
    def _get_new_image(self, predicted, frame_size):
        """ Get the new face from the predictor and apply pre-warp manipulations.

        Applies any requested adjustments to the raw output of the Faceswap model
        before transforming the image into the target frame.

        Parameters
        ----------
        predicted: dict
            The output from :class:`scripts.convert.Predictor`.
        frame_size: tuple
            The (`width`, `height`) of the final frame in pixels

        Returns
        -------
        placeholder:  :class: `numpy.ndarray`
            The original frame with the swapped faces patched onto it
        background:  :class: `numpy.ndarray`
            The original frame
        """
    def _get_new_image(self, predicted, frame_size):
        """ Get the new face from the predictor and apply pre-warp manipulations.

        Applies any requested adjustments to the raw output of the Faceswap model
        before transforming the image into the target frame.

        Parameters
        ----------
        predicted: dict
            The output from :class:`scripts.convert.Predictor`.
        frame_size: tuple
            The (`width`, `height`) of the final frame in pixels

        Returns
        -------
        placeholder:  :class: `numpy.ndarray`
            The original frame with the swapped faces patched onto it
        background:  :class: `numpy.ndarray`
            The original frame
        """
          logger.trace("Getting: (filename: '%s', faces: %s)",
                       predicted["filename"], len(predicted["swapped_faces"]))
  
          placeholder = np.zeros((frame_size[1], frame_size[0], 4), dtype="float32")
          background = predicted["image"] / np.array(255.0, dtype="float32")
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/convert.py