                  imgfile = os.path.join(scriptpath, img)
                  cv2.imwrite(imgfile, image)
              if self.args.redirect_gui:
                  img = ".gui_preview_{}.jpg".format(name)
                  imgfile = os.path.join(scriptpath, "lib", "gui", ".cache", "preview", img)
                  cv2.imwrite(imgfile, image)
              if self.args.preview:
                  with self.lock:
                      self.preview_buffer[name] = image
          except Exception as err:
 
</s> remove                 Utils.cv2_read_write('write', filename, image)
 </s> add                 cv2.imwrite(filename, image) </s> remove             if skip != "discard":
 </s> add  </s> remove             final_faces = [self.process_single_face(idx,
                                                    face,
                                                    filename,
                                                    image)
                           for idx, face in process_faces]
 </s> add     def process_item_count(self):
        """ Return the number of items to be processedd """
        processed = sum(os.path.basename(frame) in self.alignments.data.keys()
                        for frame in self.images.input_images) </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
                imgfile = os.path.join(scriptpath, "lib", "gui",
                                       ".cache", "preview", img)
                  imgfile = os.path.join(scriptpath, img)
                  cv2.imwrite(imgfile, image)
              if self.args.redirect_gui:
                  img = ".gui_preview_{}.jpg".format(name)
                imgfile = os.path.join(scriptpath, "lib", "gui",
                                       ".cache", "preview", img)
                  cv2.imwrite(imgfile, image)
              if self.args.preview:
                  with self.lock:
                      self.preview_buffer[name] = image
          except Exception as err:
keep keep keep keep 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/train.py