  
      def detect_faces(self, *args, **kwargs):
          """ Detect faces in rgb image """
          super().detect_faces(*args, **kwargs)
          try:
              while True:
                  exhausted, batch = self.get_batch()
                  if not batch:
                      break
                  filenames, images = map(list, zip(*batch))
                  detect_images = self.compile_detection_images(images)
                  batch_detected = self.detect_batch(detect_images)
                  processed = self.process_output(batch_detected,
                                                  indexes=None,
                                                  rotation_matrix=None,
                                                  output=None)
                  if not all(faces
                             for faces in processed) and self.rotation != [0]:
                      processed = self.process_rotations(detect_images,
                                                         processed)
                  for idx, faces in enumerate(processed):
                      retval = {"filename": filenames[idx],
                                "image": images[idx],
                                "detected_faces": faces}
                      self.finalize(retval)
                  if exhausted:
                      break
          except:
              retval = {"exception": True}
              self.queues["out"].put(retval)
              del self.detector  # Free up VRAM
              raise
  
          self.queues["out"].put("EOF")
          del self.detector  # Free up VRAM
  
      def compile_detection_images(self, images):
          """ Compile the detection images into batches """
 
</s> remove                 detected_faces = self.process_output(faces, rotmat)
                retval = {"filename": filename,
                          "image": image,
                          "detected_faces": detected_faces}
                self.finalize(retval)
        except:
            retval = {"exception": True}
            self.queues["out"].put(retval)
            raise
 </s> add             detected_faces = self.process_output(faces, rotmat)
            item["detected_faces"] = detected_faces
            self.finalize(item) </s> remove                 filename, image = item
                detect_image = self.compile_detection_image(image, False, False)

                for angle in self.rotation:
                    current_image, rotmat = self.rotate_image(detect_image, angle)
                    faces, points = detect_face(current_image, **self.kwargs)
                    if self.verbose and angle != 0 and faces.any():
                        print("found face(s) by rotating image {} degrees".format(
                            angle))
                    if faces.any():
                        break

                detected_faces = self.process_output(faces, points, rotmat)
                retval = {
                    "filename": filename,
                    "image": image,
                    "detected_faces": detected_faces}
                self.finalize(retval)
        except:
            retval = {"exception": True}
            self.queues["out"].put(retval)
            raise
 </s> add             detected_faces = self.process_output(faces, points, rotmat)
            item["detected_faces"] = detected_faces
            self.finalize(item)

        logger.debug("Thread Completed Detect") </s> remove         try:
            while True:
                item = self.queues["in"].get()
                if item in ("EOF", "END"):
                    self.queues["in"].put("END")
                    break

                filename, image = item
                detect_image = self.compile_detection_image(image, True, True)
 </s> add         while True:
            item = self.get_item()
            if item == "EOF":
                break
            logger.trace("Detecting faces: %s", item["filename"])
            detect_image = self.compile_detection_image(item["image"], True, True)
        while True:
            exhausted, batch = self.get_batch()
            if not batch:
                break
            filenames = list()
            images = list()
            for item in batch:
                filenames.append(item["filename"])
                images.append(item["image"])
            detect_images = self.compile_detection_images(images)
            batch_detected = self.detect_batch(detect_images)
            processed = self.process_output(batch_detected,
                                            indexes=None,
                                            rotation_matrix=None,
                                            output=None)
            if not all(faces for faces in processed) and self.rotation != [0]:
                processed = self.process_rotations(detect_images, processed)
            for idx, faces in enumerate(processed):
                filename = filenames[idx]
                for b_idx, item in enumerate(batch):
                    if item["filename"] == filename:
                        output = item
                        del_idx = b_idx
                        break
                output["detected_faces"] = faces
                self.finalize(output)
                del batch[del_idx]
            if exhausted:
                break
  
      def detect_faces(self, *args, **kwargs):
          """ Detect faces in rgb image """
          super().detect_faces(*args, **kwargs)
        while True:
            exhausted, batch = self.get_batch()
            if not batch:
                break
            filenames = list()
            images = list()
            for item in batch:
                filenames.append(item["filename"])
                images.append(item["image"])
            detect_images = self.compile_detection_images(images)
            batch_detected = self.detect_batch(detect_images)
            processed = self.process_output(batch_detected,
                                            indexes=None,
                                            rotation_matrix=None,
                                            output=None)
            if not all(faces for faces in processed) and self.rotation != [0]:
                processed = self.process_rotations(detect_images, processed)
            for idx, faces in enumerate(processed):
                filename = filenames[idx]
                for b_idx, item in enumerate(batch):
                    if item["filename"] == filename:
                        output = item
                        del_idx = b_idx
                        break
                output["detected_faces"] = faces
                self.finalize(output)
                del batch[del_idx]
            if exhausted:
                break
        while True:
            exhausted, batch = self.get_batch()
            if not batch:
                break
            filenames = list()
            images = list()
            for item in batch:
                filenames.append(item["filename"])
                images.append(item["image"])
            detect_images = self.compile_detection_images(images)
            batch_detected = self.detect_batch(detect_images)
            processed = self.process_output(batch_detected,
                                            indexes=None,
                                            rotation_matrix=None,
                                            output=None)
            if not all(faces for faces in processed) and self.rotation != [0]:
                processed = self.process_rotations(detect_images, processed)
            for idx, faces in enumerate(processed):
                filename = filenames[idx]
                for b_idx, item in enumerate(batch):
                    if item["filename"] == filename:
                        output = item
                        del_idx = b_idx
                        break
                output["detected_faces"] = faces
                self.finalize(output)
                del batch[del_idx]
            if exhausted:
                break
        while True:
            exhausted, batch = self.get_batch()
            if not batch:
                break
            filenames = list()
            images = list()
            for item in batch:
                filenames.append(item["filename"])
                images.append(item["image"])
            detect_images = self.compile_detection_images(images)
            batch_detected = self.detect_batch(detect_images)
            processed = self.process_output(batch_detected,
                                            indexes=None,
                                            rotation_matrix=None,
                                            output=None)
            if not all(faces for faces in processed) and self.rotation != [0]:
                processed = self.process_rotations(detect_images, processed)
            for idx, faces in enumerate(processed):
                filename = filenames[idx]
                for b_idx, item in enumerate(batch):
                    if item["filename"] == filename:
                        output = item
                        del_idx = b_idx
                        break
                output["detected_faces"] = faces
                self.finalize(output)
                del batch[del_idx]
            if exhausted:
                break
        while True:
            exhausted, batch = self.get_batch()
            if not batch:
                break
            filenames = list()
            images = list()
            for item in batch:
                filenames.append(item["filename"])
                images.append(item["image"])
            detect_images = self.compile_detection_images(images)
            batch_detected = self.detect_batch(detect_images)
            processed = self.process_output(batch_detected,
                                            indexes=None,
                                            rotation_matrix=None,
                                            output=None)
            if not all(faces for faces in processed) and self.rotation != [0]:
                processed = self.process_rotations(detect_images, processed)
            for idx, faces in enumerate(processed):
                filename = filenames[idx]
                for b_idx, item in enumerate(batch):
                    if item["filename"] == filename:
                        output = item
                        del_idx = b_idx
                        break
                output["detected_faces"] = faces
                self.finalize(output)
                del batch[del_idx]
            if exhausted:
                break
        while True:
            exhausted, batch = self.get_batch()
            if not batch:
                break
            filenames = list()
            images = list()
            for item in batch:
                filenames.append(item["filename"])
                images.append(item["image"])
            detect_images = self.compile_detection_images(images)
            batch_detected = self.detect_batch(detect_images)
            processed = self.process_output(batch_detected,
                                            indexes=None,
                                            rotation_matrix=None,
                                            output=None)
            if not all(faces for faces in processed) and self.rotation != [0]:
                processed = self.process_rotations(detect_images, processed)
            for idx, faces in enumerate(processed):
                filename = filenames[idx]
                for b_idx, item in enumerate(batch):
                    if item["filename"] == filename:
                        output = item
                        del_idx = b_idx
                        break
                output["detected_faces"] = faces
                self.finalize(output)
                del batch[del_idx]
            if exhausted:
                break
        while True:
            exhausted, batch = self.get_batch()
            if not batch:
                break
            filenames = list()
            images = list()
            for item in batch:
                filenames.append(item["filename"])
                images.append(item["image"])
            detect_images = self.compile_detection_images(images)
            batch_detected = self.detect_batch(detect_images)
            processed = self.process_output(batch_detected,
                                            indexes=None,
                                            rotation_matrix=None,
                                            output=None)
            if not all(faces for faces in processed) and self.rotation != [0]:
                processed = self.process_rotations(detect_images, processed)
            for idx, faces in enumerate(processed):
                filename = filenames[idx]
                for b_idx, item in enumerate(batch):
                    if item["filename"] == filename:
                        output = item
                        del_idx = b_idx
                        break
                output["detected_faces"] = faces
                self.finalize(output)
                del batch[del_idx]
            if exhausted:
                break
        while True:
            exhausted, batch = self.get_batch()
            if not batch:
                break
            filenames = list()
            images = list()
            for item in batch:
                filenames.append(item["filename"])
                images.append(item["image"])
            detect_images = self.compile_detection_images(images)
            batch_detected = self.detect_batch(detect_images)
            processed = self.process_output(batch_detected,
                                            indexes=None,
                                            rotation_matrix=None,
                                            output=None)
            if not all(faces for faces in processed) and self.rotation != [0]:
                processed = self.process_rotations(detect_images, processed)
            for idx, faces in enumerate(processed):
                filename = filenames[idx]
                for b_idx, item in enumerate(batch):
                    if item["filename"] == filename:
                        output = item
                        del_idx = b_idx
                        break
                output["detected_faces"] = faces
                self.finalize(output)
                del batch[del_idx]
            if exhausted:
                break
        while True:
            exhausted, batch = self.get_batch()
            if not batch:
                break
            filenames = list()
            images = list()
            for item in batch:
                filenames.append(item["filename"])
                images.append(item["image"])
            detect_images = self.compile_detection_images(images)
            batch_detected = self.detect_batch(detect_images)
            processed = self.process_output(batch_detected,
                                            indexes=None,
                                            rotation_matrix=None,
                                            output=None)
            if not all(faces for faces in processed) and self.rotation != [0]:
                processed = self.process_rotations(detect_images, processed)
            for idx, faces in enumerate(processed):
                filename = filenames[idx]
                for b_idx, item in enumerate(batch):
                    if item["filename"] == filename:
                        output = item
                        del_idx = b_idx
                        break
                output["detected_faces"] = faces
                self.finalize(output)
                del batch[del_idx]
            if exhausted:
                break
        while True:
            exhausted, batch = self.get_batch()
            if not batch:
                break
            filenames = list()
            images = list()
            for item in batch:
                filenames.append(item["filename"])
                images.append(item["image"])
            detect_images = self.compile_detection_images(images)
            batch_detected = self.detect_batch(detect_images)
            processed = self.process_output(batch_detected,
                                            indexes=None,
                                            rotation_matrix=None,
                                            output=None)
            if not all(faces for faces in processed) and self.rotation != [0]:
                processed = self.process_rotations(detect_images, processed)
            for idx, faces in enumerate(processed):
                filename = filenames[idx]
                for b_idx, item in enumerate(batch):
                    if item["filename"] == filename:
                        output = item
                        del_idx = b_idx
                        break
                output["detected_faces"] = faces
                self.finalize(output)
                del batch[del_idx]
            if exhausted:
                break
        while True:
            exhausted, batch = self.get_batch()
            if not batch:
                break
            filenames = list()
            images = list()
            for item in batch:
                filenames.append(item["filename"])
                images.append(item["image"])
            detect_images = self.compile_detection_images(images)
            batch_detected = self.detect_batch(detect_images)
            processed = self.process_output(batch_detected,
                                            indexes=None,
                                            rotation_matrix=None,
                                            output=None)
            if not all(faces for faces in processed) and self.rotation != [0]:
                processed = self.process_rotations(detect_images, processed)
            for idx, faces in enumerate(processed):
                filename = filenames[idx]
                for b_idx, item in enumerate(batch):
                    if item["filename"] == filename:
                        output = item
                        del_idx = b_idx
                        break
                output["detected_faces"] = faces
                self.finalize(output)
                del batch[del_idx]
            if exhausted:
                break
        while True:
            exhausted, batch = self.get_batch()
            if not batch:
                break
            filenames = list()
            images = list()
            for item in batch:
                filenames.append(item["filename"])
                images.append(item["image"])
            detect_images = self.compile_detection_images(images)
            batch_detected = self.detect_batch(detect_images)
            processed = self.process_output(batch_detected,
                                            indexes=None,
                                            rotation_matrix=None,
                                            output=None)
            if not all(faces for faces in processed) and self.rotation != [0]:
                processed = self.process_rotations(detect_images, processed)
            for idx, faces in enumerate(processed):
                filename = filenames[idx]
                for b_idx, item in enumerate(batch):
                    if item["filename"] == filename:
                        output = item
                        del_idx = b_idx
                        break
                output["detected_faces"] = faces
                self.finalize(output)
                del batch[del_idx]
            if exhausted:
                break
        while True:
            exhausted, batch = self.get_batch()
            if not batch:
                break
            filenames = list()
            images = list()
            for item in batch:
                filenames.append(item["filename"])
                images.append(item["image"])
            detect_images = self.compile_detection_images(images)
            batch_detected = self.detect_batch(detect_images)
            processed = self.process_output(batch_detected,
                                            indexes=None,
                                            rotation_matrix=None,
                                            output=None)
            if not all(faces for faces in processed) and self.rotation != [0]:
                processed = self.process_rotations(detect_images, processed)
            for idx, faces in enumerate(processed):
                filename = filenames[idx]
                for b_idx, item in enumerate(batch):
                    if item["filename"] == filename:
                        output = item
                        del_idx = b_idx
                        break
                output["detected_faces"] = faces
                self.finalize(output)
                del batch[del_idx]
            if exhausted:
                break
        while True:
            exhausted, batch = self.get_batch()
            if not batch:
                break
            filenames = list()
            images = list()
            for item in batch:
                filenames.append(item["filename"])
                images.append(item["image"])
            detect_images = self.compile_detection_images(images)
            batch_detected = self.detect_batch(detect_images)
            processed = self.process_output(batch_detected,
                                            indexes=None,
                                            rotation_matrix=None,
                                            output=None)
            if not all(faces for faces in processed) and self.rotation != [0]:
                processed = self.process_rotations(detect_images, processed)
            for idx, faces in enumerate(processed):
                filename = filenames[idx]
                for b_idx, item in enumerate(batch):
                    if item["filename"] == filename:
                        output = item
                        del_idx = b_idx
                        break
                output["detected_faces"] = faces
                self.finalize(output)
                del batch[del_idx]
            if exhausted:
                break
        while True:
            exhausted, batch = self.get_batch()
            if not batch:
                break
            filenames = list()
            images = list()
            for item in batch:
                filenames.append(item["filename"])
                images.append(item["image"])
            detect_images = self.compile_detection_images(images)
            batch_detected = self.detect_batch(detect_images)
            processed = self.process_output(batch_detected,
                                            indexes=None,
                                            rotation_matrix=None,
                                            output=None)
            if not all(faces for faces in processed) and self.rotation != [0]:
                processed = self.process_rotations(detect_images, processed)
            for idx, faces in enumerate(processed):
                filename = filenames[idx]
                for b_idx, item in enumerate(batch):
                    if item["filename"] == filename:
                        output = item
                        del_idx = b_idx
                        break
                output["detected_faces"] = faces
                self.finalize(output)
                del batch[del_idx]
            if exhausted:
                break
        while True:
            exhausted, batch = self.get_batch()
            if not batch:
                break
            filenames = list()
            images = list()
            for item in batch:
                filenames.append(item["filename"])
                images.append(item["image"])
            detect_images = self.compile_detection_images(images)
            batch_detected = self.detect_batch(detect_images)
            processed = self.process_output(batch_detected,
                                            indexes=None,
                                            rotation_matrix=None,
                                            output=None)
            if not all(faces for faces in processed) and self.rotation != [0]:
                processed = self.process_rotations(detect_images, processed)
            for idx, faces in enumerate(processed):
                filename = filenames[idx]
                for b_idx, item in enumerate(batch):
                    if item["filename"] == filename:
                        output = item
                        del_idx = b_idx
                        break
                output["detected_faces"] = faces
                self.finalize(output)
                del batch[del_idx]
            if exhausted:
                break
        while True:
            exhausted, batch = self.get_batch()
            if not batch:
                break
            filenames = list()
            images = list()
            for item in batch:
                filenames.append(item["filename"])
                images.append(item["image"])
            detect_images = self.compile_detection_images(images)
            batch_detected = self.detect_batch(detect_images)
            processed = self.process_output(batch_detected,
                                            indexes=None,
                                            rotation_matrix=None,
                                            output=None)
            if not all(faces for faces in processed) and self.rotation != [0]:
                processed = self.process_rotations(detect_images, processed)
            for idx, faces in enumerate(processed):
                filename = filenames[idx]
                for b_idx, item in enumerate(batch):
                    if item["filename"] == filename:
                        output = item
                        del_idx = b_idx
                        break
                output["detected_faces"] = faces
                self.finalize(output)
                del batch[del_idx]
            if exhausted:
                break
        while True:
            exhausted, batch = self.get_batch()
            if not batch:
                break
            filenames = list()
            images = list()
            for item in batch:
                filenames.append(item["filename"])
                images.append(item["image"])
            detect_images = self.compile_detection_images(images)
            batch_detected = self.detect_batch(detect_images)
            processed = self.process_output(batch_detected,
                                            indexes=None,
                                            rotation_matrix=None,
                                            output=None)
            if not all(faces for faces in processed) and self.rotation != [0]:
                processed = self.process_rotations(detect_images, processed)
            for idx, faces in enumerate(processed):
                filename = filenames[idx]
                for b_idx, item in enumerate(batch):
                    if item["filename"] == filename:
                        output = item
                        del_idx = b_idx
                        break
                output["detected_faces"] = faces
                self.finalize(output)
                del batch[del_idx]
            if exhausted:
                break
        while True:
            exhausted, batch = self.get_batch()
            if not batch:
                break
            filenames = list()
            images = list()
            for item in batch:
                filenames.append(item["filename"])
                images.append(item["image"])
            detect_images = self.compile_detection_images(images)
            batch_detected = self.detect_batch(detect_images)
            processed = self.process_output(batch_detected,
                                            indexes=None,
                                            rotation_matrix=None,
                                            output=None)
            if not all(faces for faces in processed) and self.rotation != [0]:
                processed = self.process_rotations(detect_images, processed)
            for idx, faces in enumerate(processed):
                filename = filenames[idx]
                for b_idx, item in enumerate(batch):
                    if item["filename"] == filename:
                        output = item
                        del_idx = b_idx
                        break
                output["detected_faces"] = faces
                self.finalize(output)
                del batch[del_idx]
            if exhausted:
                break
        while True:
            exhausted, batch = self.get_batch()
            if not batch:
                break
            filenames = list()
            images = list()
            for item in batch:
                filenames.append(item["filename"])
                images.append(item["image"])
            detect_images = self.compile_detection_images(images)
            batch_detected = self.detect_batch(detect_images)
            processed = self.process_output(batch_detected,
                                            indexes=None,
                                            rotation_matrix=None,
                                            output=None)
            if not all(faces for faces in processed) and self.rotation != [0]:
                processed = self.process_rotations(detect_images, processed)
            for idx, faces in enumerate(processed):
                filename = filenames[idx]
                for b_idx, item in enumerate(batch):
                    if item["filename"] == filename:
                        output = item
                        del_idx = b_idx
                        break
                output["detected_faces"] = faces
                self.finalize(output)
                del batch[del_idx]
            if exhausted:
                break
        while True:
            exhausted, batch = self.get_batch()
            if not batch:
                break
            filenames = list()
            images = list()
            for item in batch:
                filenames.append(item["filename"])
                images.append(item["image"])
            detect_images = self.compile_detection_images(images)
            batch_detected = self.detect_batch(detect_images)
            processed = self.process_output(batch_detected,
                                            indexes=None,
                                            rotation_matrix=None,
                                            output=None)
            if not all(faces for faces in processed) and self.rotation != [0]:
                processed = self.process_rotations(detect_images, processed)
            for idx, faces in enumerate(processed):
                filename = filenames[idx]
                for b_idx, item in enumerate(batch):
                    if item["filename"] == filename:
                        output = item
                        del_idx = b_idx
                        break
                output["detected_faces"] = faces
                self.finalize(output)
                del batch[del_idx]
            if exhausted:
                break
        while True:
            exhausted, batch = self.get_batch()
            if not batch:
                break
            filenames = list()
            images = list()
            for item in batch:
                filenames.append(item["filename"])
                images.append(item["image"])
            detect_images = self.compile_detection_images(images)
            batch_detected = self.detect_batch(detect_images)
            processed = self.process_output(batch_detected,
                                            indexes=None,
                                            rotation_matrix=None,
                                            output=None)
            if not all(faces for faces in processed) and self.rotation != [0]:
                processed = self.process_rotations(detect_images, processed)
            for idx, faces in enumerate(processed):
                filename = filenames[idx]
                for b_idx, item in enumerate(batch):
                    if item["filename"] == filename:
                        output = item
                        del_idx = b_idx
                        break
                output["detected_faces"] = faces
                self.finalize(output)
                del batch[del_idx]
            if exhausted:
                break
        while True:
            exhausted, batch = self.get_batch()
            if not batch:
                break
            filenames = list()
            images = list()
            for item in batch:
                filenames.append(item["filename"])
                images.append(item["image"])
            detect_images = self.compile_detection_images(images)
            batch_detected = self.detect_batch(detect_images)
            processed = self.process_output(batch_detected,
                                            indexes=None,
                                            rotation_matrix=None,
                                            output=None)
            if not all(faces for faces in processed) and self.rotation != [0]:
                processed = self.process_rotations(detect_images, processed)
            for idx, faces in enumerate(processed):
                filename = filenames[idx]
                for b_idx, item in enumerate(batch):
                    if item["filename"] == filename:
                        output = item
                        del_idx = b_idx
                        break
                output["detected_faces"] = faces
                self.finalize(output)
                del batch[del_idx]
            if exhausted:
                break
        while True:
            exhausted, batch = self.get_batch()
            if not batch:
                break
            filenames = list()
            images = list()
            for item in batch:
                filenames.append(item["filename"])
                images.append(item["image"])
            detect_images = self.compile_detection_images(images)
            batch_detected = self.detect_batch(detect_images)
            processed = self.process_output(batch_detected,
                                            indexes=None,
                                            rotation_matrix=None,
                                            output=None)
            if not all(faces for faces in processed) and self.rotation != [0]:
                processed = self.process_rotations(detect_images, processed)
            for idx, faces in enumerate(processed):
                filename = filenames[idx]
                for b_idx, item in enumerate(batch):
                    if item["filename"] == filename:
                        output = item
                        del_idx = b_idx
                        break
                output["detected_faces"] = faces
                self.finalize(output)
                del batch[del_idx]
            if exhausted:
                break
        while True:
            exhausted, batch = self.get_batch()
            if not batch:
                break
            filenames = list()
            images = list()
            for item in batch:
                filenames.append(item["filename"])
                images.append(item["image"])
            detect_images = self.compile_detection_images(images)
            batch_detected = self.detect_batch(detect_images)
            processed = self.process_output(batch_detected,
                                            indexes=None,
                                            rotation_matrix=None,
                                            output=None)
            if not all(faces for faces in processed) and self.rotation != [0]:
                processed = self.process_rotations(detect_images, processed)
            for idx, faces in enumerate(processed):
                filename = filenames[idx]
                for b_idx, item in enumerate(batch):
                    if item["filename"] == filename:
                        output = item
                        del_idx = b_idx
                        break
                output["detected_faces"] = faces
                self.finalize(output)
                del batch[del_idx]
            if exhausted:
                break
        while True:
            exhausted, batch = self.get_batch()
            if not batch:
                break
            filenames = list()
            images = list()
            for item in batch:
                filenames.append(item["filename"])
                images.append(item["image"])
            detect_images = self.compile_detection_images(images)
            batch_detected = self.detect_batch(detect_images)
            processed = self.process_output(batch_detected,
                                            indexes=None,
                                            rotation_matrix=None,
                                            output=None)
            if not all(faces for faces in processed) and self.rotation != [0]:
                processed = self.process_rotations(detect_images, processed)
            for idx, faces in enumerate(processed):
                filename = filenames[idx]
                for b_idx, item in enumerate(batch):
                    if item["filename"] == filename:
                        output = item
                        del_idx = b_idx
                        break
                output["detected_faces"] = faces
                self.finalize(output)
                del batch[del_idx]
            if exhausted:
                break
        while True:
            exhausted, batch = self.get_batch()
            if not batch:
                break
            filenames = list()
            images = list()
            for item in batch:
                filenames.append(item["filename"])
                images.append(item["image"])
            detect_images = self.compile_detection_images(images)
            batch_detected = self.detect_batch(detect_images)
            processed = self.process_output(batch_detected,
                                            indexes=None,
                                            rotation_matrix=None,
                                            output=None)
            if not all(faces for faces in processed) and self.rotation != [0]:
                processed = self.process_rotations(detect_images, processed)
            for idx, faces in enumerate(processed):
                filename = filenames[idx]
                for b_idx, item in enumerate(batch):
                    if item["filename"] == filename:
                        output = item
                        del_idx = b_idx
                        break
                output["detected_faces"] = faces
                self.finalize(output)
                del batch[del_idx]
            if exhausted:
                break
        while True:
            exhausted, batch = self.get_batch()
            if not batch:
                break
            filenames = list()
            images = list()
            for item in batch:
                filenames.append(item["filename"])
                images.append(item["image"])
            detect_images = self.compile_detection_images(images)
            batch_detected = self.detect_batch(detect_images)
            processed = self.process_output(batch_detected,
                                            indexes=None,
                                            rotation_matrix=None,
                                            output=None)
            if not all(faces for faces in processed) and self.rotation != [0]:
                processed = self.process_rotations(detect_images, processed)
            for idx, faces in enumerate(processed):
                filename = filenames[idx]
                for b_idx, item in enumerate(batch):
                    if item["filename"] == filename:
                        output = item
                        del_idx = b_idx
                        break
                output["detected_faces"] = faces
                self.finalize(output)
                del batch[del_idx]
            if exhausted:
                break
        while True:
            exhausted, batch = self.get_batch()
            if not batch:
                break
            filenames = list()
            images = list()
            for item in batch:
                filenames.append(item["filename"])
                images.append(item["image"])
            detect_images = self.compile_detection_images(images)
            batch_detected = self.detect_batch(detect_images)
            processed = self.process_output(batch_detected,
                                            indexes=None,
                                            rotation_matrix=None,
                                            output=None)
            if not all(faces for faces in processed) and self.rotation != [0]:
                processed = self.process_rotations(detect_images, processed)
            for idx, faces in enumerate(processed):
                filename = filenames[idx]
                for b_idx, item in enumerate(batch):
                    if item["filename"] == filename:
                        output = item
                        del_idx = b_idx
                        break
                output["detected_faces"] = faces
                self.finalize(output)
                del batch[del_idx]
            if exhausted:
                break
        while True:
            exhausted, batch = self.get_batch()
            if not batch:
                break
            filenames = list()
            images = list()
            for item in batch:
                filenames.append(item["filename"])
                images.append(item["image"])
            detect_images = self.compile_detection_images(images)
            batch_detected = self.detect_batch(detect_images)
            processed = self.process_output(batch_detected,
                                            indexes=None,
                                            rotation_matrix=None,
                                            output=None)
            if not all(faces for faces in processed) and self.rotation != [0]:
                processed = self.process_rotations(detect_images, processed)
            for idx, faces in enumerate(processed):
                filename = filenames[idx]
                for b_idx, item in enumerate(batch):
                    if item["filename"] == filename:
                        output = item
                        del_idx = b_idx
                        break
                output["detected_faces"] = faces
                self.finalize(output)
                del batch[del_idx]
            if exhausted:
                break
          self.queues["out"].put("EOF")
          del self.detector  # Free up VRAM
  
      def compile_detection_images(self, images):
          """ Compile the detection images into batches """
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
 Logging (#541)

* Convert prints to logger. Further logging improvements. Tidy  up

* Fix system verbosity. Allow SystemExit

* Fix reload extract bug

* Child Traceback handling

* Safer shutdown procedure

* Add shutdown event to queue manager

* landmarks_as_xy > property. GUI notes + linting. Aligner bugfix

* fix FaceFilter. Enable nFilter when no Filter is supplied

* Fix blurry face filter

* Continue on IO error. Better error handling

* Explicitly print stack trace tocrash log

* Windows Multiprocessing bugfix

* Add git info and conda version to crash log

* Windows/Anaconda mp bugfix

* Logging fixes for training 
plugins/extract/detect/dlib_cnn.py