  
          logger.info("Sorting...")
          return sorted(img_list, key=lambda x: x[2], reverse=True)
  
      def sort_color(self):
          """ Score by channel average intensity """
          logger.info("Sorting by channel average intensity...")
          desired_channel = {'gray': 0, 'luma': 0, 'orange': 1, 'green': 2}
          method = self._args.color_method
          channel_to_sort = next(v for (k, v) in desired_channel.items() if method.endswith(k))
          filename_list, image_list = self._get_images()
  
          logger.info("Converting to appropriate colorspace...")
          same_size = all(img.size == image_list[0].size for img in image_list)
          images = np.array(image_list, dtype='float32')[None, ...] if same_size else image_list
          converted_images = self._convert_color(images, same_size, method)
  
          logger.info("Scoring each image...")
          if same_size:
              scores = np.average(converted_images[0], axis=(1, 2))
          else:
              progress_bar = tqdm(converted_images, desc="Scoring", file=sys.stdout)
              scores = np.array([np.average(image, axis=(0, 1)) for image in progress_bar])
  
          logger.info("Sorting...")
          matched_list = list(zip(filename_list, scores[:, channel_to_sort]))
          sorted_file_img_list = sorted(matched_list, key=operator.itemgetter(1), reverse=True)
          return sorted_file_img_list
  
      def sort_size(self):
          """ Sort the faces by largest face (in original frame) to smallest """
          logger.info("Sorting by original face size...")
          img_list = []
          for filename, image, metadata in tqdm(self._loader.load(),
 
</s> remove         if self._globals.filter_mode != "No Faces":
            for frame_idx, face_count in enumerate(self._detected_faces.face_count_per_index):
                if face_count <= 1 and self._globals.filter_mode == "Multiple Faces":
                    continue
                for face_idx in range(face_count):
                    frame_indices.append(frame_idx)
                    face_indices.append(face_idx)
        logger.trace("frame_indices: %s, face_indices: %s", frame_indices, face_indices)
 </s> add         face_counts = self._detected_faces.face_count_per_index  # Copy to avoid recalculations

        for frame_idx in self.frames_list:
            for face_idx in range(face_counts[frame_idx]):
                frame_indices.append(frame_idx)
                face_indices.append(face_idx)
 </s> remove             size = ((roi[1][0] - roi[0][0]) ** 2 + (roi[1][1] - roi[0][1]) ** 2) ** 0.5
 </s> add             size = ((roi[1][0] - roi[0][0]) ** 2 +  # pylint:disable=unsubscriptable-object
                    (roi[1][1] - roi[0][1]) ** 2) ** 0.5  # pylint:disable=unsubscriptable-object </s> remove             var.set(0)
 </s> add             var.set(10 if name == "filter_distance" else 0)
  
          logger.info("Sorting...")
          return sorted(img_list, key=lambda x: x[2], reverse=True)
  

























      def sort_size(self):
          """ Sort the faces by largest face (in original frame) to smallest """
          logger.info("Sorting by original face size...")
          img_list = []
          for filename, image, metadata in tqdm(self._loader.load(),
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 keep keep keep keep keep
 Add Misalignment Detection
  - lib.align.AlignedFace - Add average_distance property (distance from mean_face)
  - tools.manual - Add misaligned Faces filter
  - tools.sort - Add sort by distance (misaligned sort)Add "Misaligned Faces" filter to manual tool 
tools/sort/sort.py