      def remove_alignment(self, item):
          """ Remove the alignment from the alignments file """
          del_count = 0
          frame_name, alignments, number_alignments = item[:3]
          processor = self.alignments.yield_original_index_reverse
          for idx in processor(alignments, number_alignments):
              face_indexes = self.items.items.get(frame_name, [-1])
              if idx not in face_indexes:
                  del alignments[idx]
                  self.removed.add(frame_name)
                  logger.verbose("Removed alignment data for image: '%s'"
 
</s> remove                 logger.verbose("Removed alignment data for image: '%s'"
                               "index: %s", frame_name, str(idx))
 </s> add                 logger.verbose("Removed alignment data for image: '%s' index: %s",
                               frame_name, str(idx)) </s> remove         return self.remove_alignment(item)

    def faces_count_matches(self, item):
        """ Check the selected face exits """
        frame_name, number_alignments = item[0], item[2]
        number_faces = len(self.items.items.get(frame_name, list()))
        return bool(number_alignments in(0, number_faces))
 </s> add         pre_face_count = self.alignments.faces_count
        self.alignments.filter_hashes(face_hashes, filter_out=False)
        post_face_count = self.alignments.faces_count
        return pre_face_count - post_face_count </s> remove                               desc="Sort alignment indexes",
                              total=self.alignments.frames_count):
 </s> add                               desc="Sort alignment indexes", total=self.alignments.frames_count): </s> remove     def rename_faces(self):
        """ Rename the aligned faces to match their "
            new index in alignments file """
        current_frame = ""
        current_index = 0
        rename_count = 0
        for face in tqdm(self.items.file_list_sorted,
                         desc="Renaming aligned faces",
                         total=self.items.count):

            if face["frame_name"] not in self.removed:
                continue
            current_index, current_frame = self.set_image_index(
                current_index,
                current_frame,
                face["frame_name"])
            if current_index != face["face_index"]:
                rename_count += self.rename_file(face,
                                                 current_frame,
                                                 current_index)

            current_index += 1
        if rename_count == 0:
            logger.info("No files were renamed. Exiting")
            return
        logger.info("%s face(s) were renamed to match with alignments file", rename_count)

    @staticmethod
    def set_image_index(index, current, original):
        """ Set the current processing image and index """
        idx = 0 if current != original else index
        return idx, original

    def rename_file(self, face, frame_name, index):
        """ Rename the selected file """
        old_file = face["face_name"] + face["face_extension"]
        new_file = "{}_{}{}".format(frame_name,
                                    str(index),
                                    face["face_extension"])
        src = os.path.join(self.items.folder, old_file)
        dst = os.path.join(self.items.folder, new_file)
        os.rename(src, dst)
        logger.verbose("Renamed '%s' to '%s'", src, dst)
        return 1

 </s> add 
        for idx in self.alignments.yield_original_index_reverse(alignments, number_alignments):
      def remove_alignment(self, item):
          """ Remove the alignment from the alignments file """
          del_count = 0
          frame_name, alignments, number_alignments = item[:3]
        for idx in self.alignments.yield_original_index_reverse(alignments, number_alignments):
        for idx in self.alignments.yield_original_index_reverse(alignments, number_alignments):
              face_indexes = self.items.items.get(frame_name, [-1])
              if idx not in face_indexes:
                  del alignments[idx]
                  self.removed.add(frame_name)
                  logger.verbose("Removed alignment data for image: '%s'"
keep keep keep keep replace replace keep keep keep keep keep
 Add Face Hashes to Alignments (#550)

* Convert main scripts to use face hashes

* Alignment tool: Use hashes, add logging, add face rename function

* More logging. Update Manual tool to work with hashing 
tools/lib_alignments/jobs.py