                  "alignments.{}".format(self.serializer.ext))
          print("Alignments filepath: %s" % alignfile)
          return alignfile
  
      def read_alignments(self):
          """ Read the serialized alignments file """
          try:
              with open(self.alignments_path, self.serializer.roptions) as align:
                  faces_detected = self.serializer.unmarshal(align.read())
          except Exception as err:
              print("{} not read!".format(self.alignments_path))
              print(str(err))
              faces_detected = dict()
          return faces_detected
  
      def write_alignments(self, faces_detected):
          """ Write the serialized alignments file """
          if hasattr(self.args, 'skip_existing') and self.args.skip_existing:
              faces_detected = self.load_skip_alignments(self.alignments_path,
 
</s> remove     def write_alignments(self, faces_detected):
        """ Write the serialized alignments file """
        if hasattr(self.args, 'skip_existing') and self.args.skip_existing:
            faces_detected = self.load_skip_alignments(self.alignments_path,
                                                       faces_detected)
 </s> add         print("{}: {}".format(f_type.title(), f_args))
        filter_files = f_args if isinstance(f_args, list) else [f_args]
        filter_files = list(filter(lambda fnc: Path(fnc).exists(),
                                   filter_files))
        return filter_files </s> remove     def get_alignments_path(self):
        """ Return the path to alignments file """
        if self.args.alignments_path:
            alignfile = self.args.alignments_path
        else:
            alignfile = os.path.join(
                str(self.args.input_dir),
                "alignments.{}".format(self.serializer.ext))
        print("Alignments filepath: %s" % alignfile)
        return alignfile
 </s> add         if any(filters for filters in filter_files):
            facefilter = FilterFunc(filter_files[0],
                                    filter_files[1],
                                    ref_threshold)
        return facefilter </s> remove         try:
            print("Writing alignments to: {}".format(self.alignments_path))
            with open(self.alignments_path, self.serializer.woptions) as align:
                align.write(self.serializer.marshal(faces_detected))
        except Exception as err:
            print("{} not written!".format(self.alignments_path))
            print(str(err))
 </s> add     def process(self, output_item):
        """ Filter in/out wanted/unwanted faces """
        if not self.filter:
            return </s> remove     @staticmethod
    def load_extractor(extractor_name="Align"):
        """ Load the requested extractor for extraction """
        extractor = PluginLoader.get_extractor(extractor_name)()
 </s> add     def save(self):
        """ Write the serialized alignments file """
        try:
            print("Writing alignments to: {}".format(self.location))
            with open(self.location, self.serializer.woptions) as align:
                align.write(self.serializer.marshal(self.data))
        except Exception as err:
            print("{} not written!".format(self.location))
            print(str(err)) </s> remove     def load_skip_alignments(self, alignfile, faces_detected):
        """ Load existing alignments if skipping existing images """
        if self.have_alignments_file:
            existing_alignments = self.read_alignments()
            for key, val in existing_alignments.items():
                if val:
                    faces_detected[key] = val
        else:
            print("Existing alignments file '{}' not found.".format(alignfile))
        return faces_detected
 </s> add         detected_faces = output_item["detected_faces"]
        ret_faces = list()
        for face in detected_faces:
            if not self.filter.check(face):
                if self.verbose:
                    print("Skipping not recognized face!")
                continue
            ret_faces.append(face)
        output_item["detected_faces"] = ret_faces
    @staticmethod
    def set_face_filter(f_type, f_args):
        """ Set the required filters """
        if not f_args:
            return list()
                  "alignments.{}".format(self.serializer.ext))
          print("Alignments filepath: %s" % alignfile)
          return alignfile
  
    @staticmethod
    def set_face_filter(f_type, f_args):
        """ Set the required filters """
        if not f_args:
            return list()
    @staticmethod
    def set_face_filter(f_type, f_args):
        """ Set the required filters """
        if not f_args:
            return list()
    @staticmethod
    def set_face_filter(f_type, f_args):
        """ Set the required filters """
        if not f_args:
            return list()
    @staticmethod
    def set_face_filter(f_type, f_args):
        """ Set the required filters """
        if not f_args:
            return list()
    @staticmethod
    def set_face_filter(f_type, f_args):
        """ Set the required filters """
        if not f_args:
            return list()
    @staticmethod
    def set_face_filter(f_type, f_args):
        """ Set the required filters """
        if not f_args:
            return list()
    @staticmethod
    def set_face_filter(f_type, f_args):
        """ Set the required filters """
        if not f_args:
            return list()
    @staticmethod
    def set_face_filter(f_type, f_args):
        """ Set the required filters """
        if not f_args:
            return list()
    @staticmethod
    def set_face_filter(f_type, f_args):
        """ Set the required filters """
        if not f_args:
            return list()
    @staticmethod
    def set_face_filter(f_type, f_args):
        """ Set the required filters """
        if not f_args:
            return list()
  
      def write_alignments(self, faces_detected):
          """ Write the serialized alignments file """
          if hasattr(self.args, 'skip_existing') and self.args.skip_existing:
              faces_detected = self.load_skip_alignments(self.alignments_path,
keep keep keep keep replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
 Extraction - Speed improvements (#522) (#523)

* Extraction - Speed improvements (#522)

* Initial Plugin restructure

* Detectors to plugins. Detector speed improvements

* Re-implement dlib aligner, remove models, FAN to TF. Parallel processing

* Update manual, update convert, implement parallel/serial switching

* linting + fix cuda check (setup.py). requirements update keras 2.2.4

* Add extract size option. Fix dlib hog init

* GUI: Increase tooltip width

* Update alignment tool to support new DetectedFace

* Add skip existing faces option

* Fix sort tool to new plugin structure

* remove old align plugin

* fix convert -skip faces bug

* Fix convert skipping no faces frames

* Convert - draw onto transparent layer

* Fix blur threshold bug

* fix skip_faces convert bug

* Fix training 
scripts/fsmedia.py