          reset_grid = self._add_remove_faces(alignments, faces)
  
          for detected_face, face in zip(faces, alignments):
              detected_face.from_alignment(face, with_thumb=True)
  
          self._updated_frame_indices.remove(frame_index)
          if not self._updated_frame_indices:
              self._tk_unsaved.set(False)
  
          if reset_grid:
 
</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     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

 </s> add 
            detected_face.load_aligned(None, force=True)
            _ = detected_face.aligned.average_distance  # cache the distances
          reset_grid = self._add_remove_faces(alignments, faces)
  
          for detected_face, face in zip(faces, alignments):
              detected_face.from_alignment(face, with_thumb=True)
            detected_face.load_aligned(None, force=True)
            _ = detected_face.aligned.average_distance  # cache the distances
  
          self._updated_frame_indices.remove(frame_index)
          if not self._updated_frame_indices:
              self._tk_unsaved.set(False)
  
          if reset_grid:
keep keep keep add keep 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/manual/detected_faces.py