      
      def handleImage(self, filename):
          count = 0
          image = cv2.imread(filename)
          for idx, face in self.get_faces(image):
              count = idx
              resized_image = self.extractor.extract(image, face, 256)
              output_file = get_folder(self.output_dir) / Path(filename).stem
              cv2.imwrite(str(output_file) + str(idx) + Path(filename).suffix, resized_image)
          return count + 1
 
</s> remove         return count + 1

 </s> add             f = {
                "x": face.x,
                "w": face.w,
                "y": face.y,
                "h": face.h,
                "landmarksXY": face.landmarksAsXY()
            }
            rvals.append(f)
        return filename, rvals </s> remove             self.faces_detected = self.faces_detected + 1
 </s> add             self.num_faces_detected += 1 </s> remove             yield filename, image, self.get_faces(image)
 </s> add             if self.have_face(filename):
                faces = self.get_faces_alignments(filename)
            else:
                faces = self.get_faces(image)
            yield filename, image, faces </s> remove     
    def get_faces(self, image):
 </s> add     def have_face(self, filename):
        return filename in self.faces_detected

    def get_faces_alignments(self, filename):
        faces = self.get_faces(image)
        rvals = []
        for idx, face in faces:
      
      def handleImage(self, filename):
          count = 0
          image = cv2.imread(filename)
        faces = self.get_faces(image)
        rvals = []
        for idx, face in faces:
              count = idx
              resized_image = self.extractor.extract(image, face, 256)
              output_file = get_folder(self.output_dir) / Path(filename).stem
              cv2.imwrite(str(output_file) + str(idx) + Path(filename).suffix, resized_image)
          return count + 1
keep keep keep keep replace keep keep keep keep keep
 Added serializers.

This speeds up convert speed x4 on my machine. 
scripts/extract.py