          predicted = [face, mask] if mask is not None else [face]
          logger.trace("Filtered output shape(s): %s", [predict.shape for predict in predicted])
          return predicted
  
      def queue_out_frames(self, batch, swapped_faces):
          """ Compile the batch back to original frames and put to out_queue """
          logger.trace("Queueing out batch. Batchsize: %s", len(batch))
          pointer = 0
          for item in batch:
              num_faces = len(item["detected_faces"])
              if num_faces == 0:
 
</s> remove     def get_batchsize(queue_size):
        """ Get the batchsize """
 </s> add     def _get_batchsize(queue_size):
        """ Get the batch size for feeding the model.

        Sets the batch size to 1 if inference is being run on CPU, otherwise the minimum of the
        :attr:`self._queue_size` and 16.

        Returns
        -------
        int
            The batch size that the model is to be fed at.
        """ </s> remove                     feed_faces = self.compile_feed_faces(detected_batch)
 </s> add                     feed_faces = self._compile_feed_faces(detected_batch) </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     def random_choice(self):
        """ Return for random indices from the indices group """
        retval = [random.choice(indices) for indices in self.indices]
 </s> add     def sample_size(self):
        """ int: The number of samples to take from the input video/images """
        return self._sample_size

    @property
    def predicted_images(self):
        """ list: The predicted faces output from the Faceswap model """
        return self._predicted_images

    @property
    def alignments(self):
        """ :class:`~lib.alignments.Alignments`: The alignments for the preview faces """
        return self._alignments

    @property
    def predictor(self):
        """ :class:`~scripts.convert.Predict`: The Predictor for the Faceswap model """
        return self._predictor

    @property
    def _random_choice(self):
        """ list: Random indices from the :attr:`_indices` group """
        retval = [random.choice(indices) for indices in self._indices] </s> remove             self.input_images.append({"filename": filename,
                                      "image": image,
                                      "detected_faces": [detected_face]})
        self.display.source = self.input_images
        self.display.update_source = True
        logger.debug("Selected frames: %s", [frame["filename"] for frame in self.input_images])

    def predict(self):
        """ Predict from the loaded frames """
        with self.lock:
            self.predicted_images = list()
            for frame in self.input_images:
                self.predictor.in_queue.put(frame)
 </s> add             self._input_images.append({"filename": filename,
                                       "image": image,
                                       "detected_faces": [detected_face]})
        self._display.source = self._input_images
        self._display.update_source = True
        logger.debug("Selected frames: %s", [frame["filename"] for frame in self._input_images])

    def _predict(self):
        """ Predict from the loaded frames.

        With a threading lock (to prevent stacking), run the selected faces through the Faceswap
        model predict function and add the output to :attr:`predicted`
        """
        with self._lock:
            self._predicted_images = list()
            for frame in self._input_images:
                self._predictor.in_queue.put(frame)
    def _queue_out_frames(self, batch, swapped_faces):
        """ Compile the batch back to original frames and put to the Out Queue.

        For batching, faces are split away from their frames. This compiles all detected faces
        back to their parent frame before putting each frame to the out queue in batches.

        Parameters
        ----------
        batch: dict
            The batch that was used as the input for the model predict function
        swapped_faces: :class:`numpy.ndarray`
            The predictions returned from the model's predict function
        """
          predicted = [face, mask] if mask is not None else [face]
          logger.trace("Filtered output shape(s): %s", [predict.shape for predict in predicted])
          return predicted
  
    def _queue_out_frames(self, batch, swapped_faces):
        """ Compile the batch back to original frames and put to the Out Queue.

        For batching, faces are split away from their frames. This compiles all detected faces
        back to their parent frame before putting each frame to the out queue in batches.

        Parameters
        ----------
        batch: dict
            The batch that was used as the input for the model predict function
        swapped_faces: :class:`numpy.ndarray`
            The predictions returned from the model's predict function
        """
    def _queue_out_frames(self, batch, swapped_faces):
        """ Compile the batch back to original frames and put to the Out Queue.

        For batching, faces are split away from their frames. This compiles all detected faces
        back to their parent frame before putting each frame to the out queue in batches.

        Parameters
        ----------
        batch: dict
            The batch that was used as the input for the model predict function
        swapped_faces: :class:`numpy.ndarray`
            The predictions returned from the model's predict function
        """
          logger.trace("Queueing out batch. Batchsize: %s", len(batch))
          pointer = 0
          for item in batch:
              num_faces = len(item["detected_faces"])
              if num_faces == 0:
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 
scripts/convert.py