      >>>     saver.save(filename, image)
      >>> saver.close()
      """
  
      def __init__(self, path, task, load_with_hash=False, queue_size=16):
          logger.debug("Initializing %s: (path: %s, task: %s, load_with_hash: %s, queue_size: %s)",
                       self.__class__.__name__, path, task, load_with_hash, queue_size)
          self._location = path
  
          self._task = task.lower()
          self._is_video = self._check_input()
          self._input = self.location if self._is_video else get_image_paths(self.location)
          self._count = count_frames(self._input) if self._is_video else len(self._input)
 
</s> remove         self._task = task.lower()
        self._is_video = self._check_input()
        self._input = self.location if self._is_video else get_image_paths(self.location)
        self._count = count_frames(self._input) if self._is_video else len(self._input)
        self._queue = queue_manager.get_queue(name="{}_{}".format(self.__class__.__name__,
                                                                  self._task),
                                              maxsize=queue_size)
        self._thread = self._set_thread(io_args=(load_with_hash, ))
        self._thread.start()
 </s> add         self._count = None
        self._file_list = None
        self._get_count_and_filelist(fast_count) </s> remove     >>> saver = BackgroundIO('/path/to/save/folder', 'save')
    >>> for filename, image in <image_iterator>:
    >>>     saver.save(filename, image)
    >>> saver.close()
    """
 </s> add         args = (load_with_hash, )
        super().__init__(path, queue_size=queue_size, args=args)
        self._skip_list = set() if skip_list is None else set(skip_list) </s> remove     Saving out images:
 </s> add     def __init__(self, path, queue_size=8, load_with_hash=False, fast_count=True, skip_list=None):
        logger.debug("Initializing %s: (path: %s, queue_size: %s, load_with_hash: %s, "
                     "fast_count: %s)", self.__class__.__name__, path, queue_size,
                     load_with_hash, fast_count) </s> remove     # SAVING #
    @staticmethod
    def _save(*args):
 </s> add class ImagesSaver(ImageIO):
    """ Perform image saving to a destination folder.

    Images are saved in a background ThreadPoolExecutor to allow for concurrent saving.
    See also :class:`ImageIO` for additional attributes.

    Parameters
    ----------
    path: str
        The folder to save images to. This must be an existing folder.
    queue_size: int, optional
        The amount of images to hold in the internal buffer. Default: 8.
    as_bytes: bool, optional
        ``True`` if the image is already encoded to bytes, ``False`` if the image is a
        :class:`numpy.ndarray`. Default: ``False``.

    Examples
    --------

    >>> saver = ImagesSaver('/path/to/save/folder')
    >>> for filename, image in <image_iterator>:
    >>>     saver.save(filename, image)
    >>> saver.close()
    """

    def __init__(self, path, queue_size=8, as_bytes=False):
        logger.debug("Initializing %s: (path: %s, load_with_hash: %s, as_bytes: %s)",
                     self.__class__.__name__, path, queue_size, as_bytes)

        super().__init__(path, queue_size=queue_size)
        self._as_bytes = as_bytes

    def _check_location_exists(self):
        """ Check whether the output location exists and is a folder

        Raises
        ------
        FaceswapError
            If the given location does not exist or the location is not a folder
        """
        if not isinstance(self.location, str):
            raise FaceswapError("The output location must be a string not a "
                                "{}".format(type(self.location)))
        super()._check_location_exists()
        if not os.path.isdir(self.location):
            raise FaceswapError("The output location '{}' is not a folder".format(self.location))

    def _process(self, queue):
        self._is_video = self._check_for_video()
      >>>     saver.save(filename, image)
      >>> saver.close()
      """
  
        self._is_video = self._check_for_video()
        self._is_video = self._check_for_video()
        self._is_video = self._check_for_video()
        self._is_video = self._check_for_video()
  
          self._task = task.lower()
          self._is_video = self._check_input()
          self._input = self.location if self._is_video else get_image_paths(self.location)
          self._count = count_frames(self._input) if self._is_video else len(self._input)
keep keep keep keep replace replace replace replace keep keep keep keep keep
 scripts.extract - code optimizations

Limit queue sizes to reduce RAM usage
Rename lib.image.BackgroundIO to ImageIO
Create separate ImagesLoader and ImagesSaver classes
Load/Save images from centralized lib.image.ImageIO
scripts.extract documentation 
lib/image.py