  logger = logging.getLogger(__name__)  # pylint: disable=invalid-name
  
  
  class Extract():
      """ The extract process. """
      def __init__(self, arguments):
          logger.debug("Initializing %s: (args: %s", self.__class__.__name__, arguments)
          self.args = arguments
          Utils.set_verbosity(self.args.loglevel)
          self.output_dir = get_folder(self.args.output_dir)
 
</s> remove         self.args = arguments
        Utils.set_verbosity(self.args.loglevel)
        self.output_dir = get_folder(self.args.output_dir)
        logger.info("Output Directory: %s", self.args.output_dir)
        self.images = Images(self.args)
        self.alignments = Alignments(self.args, True, self.images.is_video)
        self.post_process = PostProcess(arguments)
        configfile = self.args.configfile if hasattr(self.args, "configfile") else None
        normalization = None if self.args.normalization == "none" else self.args.normalization
        self.extractor = Extractor(self.args.detector,
                                   self.args.aligner,
                                   self.args.masker,
                                   configfile=configfile,
                                   multiprocess=not self.args.singleprocess,
                                   rotate_images=self.args.rotate_images,
                                   min_size=self.args.min_size,
                                   normalize_method=normalization)
        self.save_queue = queue_manager.get_queue("extract_save")
        self.threads = list()
        self.verify_output = False
        self.save_interval = None
        if hasattr(self.args, "save_interval"):
            self.save_interval = self.args.save_interval
 </s> add         self._args = arguments
        Utils.set_verbosity(self._args.loglevel)

        self._output_dir = str(get_folder(self._args.output_dir))

        logger.info("Output Directory: %s", self._args.output_dir)
        self._images = ImagesLoader(self._args.input_dir, load_with_hash=False, fast_count=True)
        self._alignments = Alignments(self._args, True, self._images.is_video)

        self._existing_count = 0
        self._set_skip_list()

        self._post_process = PostProcess(arguments)
        configfile = self._args.configfile if hasattr(self._args, "configfile") else None
        normalization = None if self._args.normalization == "none" else self._args.normalization
        self._extractor = Extractor(self._args.detector,
                                    self._args.aligner,
                                    self._args.masker,
                                    configfile=configfile,
                                    multiprocess=not self._args.singleprocess,
                                    rotate_images=self._args.rotate_images,
                                    min_size=self._args.min_size,
                                    normalize_method=normalization)
        self._threads = list()
        self._verify_output = False </s> remove from scripts.fsmedia import Alignments, Images, PostProcess, Utils
 </s> add from scripts.fsmedia import Alignments, PostProcess, Utils </s> remove     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
 </s> add         self._is_video = self._check_for_video() </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)
    """ The Faceswap Face Extraction Process.

    The extraction process is responsible for detecting faces in a series of images/video, aligning
    these faces and then generating a mask.

    It leverages a series of user selected plugins, chained together using
    :mod:`plugins.extract.pipeline`.

    The extract process is self contained and should not be referenced by any other scripts, so it
    contains no public properties.

    Parameters
    ----------
    arguments: argparse.Namespace
        The arguments to be passed to the extraction process as generated from Faceswap's command
        line arguments
    """
  logger = logging.getLogger(__name__)  # pylint: disable=invalid-name
  
  
  class Extract():
    """ The Faceswap Face Extraction Process.

    The extraction process is responsible for detecting faces in a series of images/video, aligning
    these faces and then generating a mask.

    It leverages a series of user selected plugins, chained together using
    :mod:`plugins.extract.pipeline`.

    The extract process is self contained and should not be referenced by any other scripts, so it
    contains no public properties.

    Parameters
    ----------
    arguments: argparse.Namespace
        The arguments to be passed to the extraction process as generated from Faceswap's command
        line arguments
    """
      def __init__(self, arguments):
          logger.debug("Initializing %s: (args: %s", self.__class__.__name__, arguments)
          self.args = arguments
          Utils.set_verbosity(self.args.loglevel)
          self.output_dir = get_folder(self.args.output_dir)
keep keep keep keep 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 
scripts/extract.py