          self._update_count = 0
  
          self._check_input(arguments.input)
          self._saver = self._set_saver(arguments)
          self._loader = BackgroundIO(arguments.input,
                                      "load",
                                      load_with_hash=self._input_is_faces,
                                      queue_size=16)
          self._alignments = Alignments(os.path.dirname(arguments.alignments),
                                        filename=os.path.basename(arguments.alignments))
  
          self._extractor = self._get_extractor()
          self._extractor_input_thread = self._feed_extractor()
 
</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         saver = BackgroundIO(output_dir, "save", queue_size=16)
 </s> add         saver = ImagesSaver(output_dir) </s> remove         load_queue = self.extractor.input_queue
        idx = 0
        for filename, image in self.images.load():
            idx += 1
 </s> add         load_queue = self._extractor.input_queue
        for filename, image in self._images.load(): </s> remove         load_queue = self.extractor.input_queue
        idx = 0
        for filename, image in self.images.load():
            idx += 1
 </s> add         load_queue = self._extractor.input_queue
        for filename, image in self._images.load(): </s> remove     def load_images(self):
        """ Load the images """
 </s> add         Loads images from :class:`lib.image.ImagesLoader`, formats them into a dict compatible
        with :class:`plugins.extract.Pipeline.Extractor` and passes them into the extraction queue.
        """
        self._loader = ImagesLoader(arguments.input, load_with_hash=self._input_is_faces)
          self._update_count = 0
  
          self._check_input(arguments.input)
          self._saver = self._set_saver(arguments)
        self._loader = ImagesLoader(arguments.input, load_with_hash=self._input_is_faces)
        self._loader = ImagesLoader(arguments.input, load_with_hash=self._input_is_faces)
        self._loader = ImagesLoader(arguments.input, load_with_hash=self._input_is_faces)
        self._loader = ImagesLoader(arguments.input, load_with_hash=self._input_is_faces)
          self._alignments = Alignments(os.path.dirname(arguments.alignments),
                                        filename=os.path.basename(arguments.alignments))
  
          self._extractor = self._get_extractor()
          self._extractor_input_thread = self._feed_extractor()
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 
tools/mask.py