          input_dir = self.args.input_dir
  
          logger.info("Sorting by face similarity...")
  
          img_list = [[img, self.vgg_face.predict(cv2.imread(img))]
                      for img in
                      tqdm(self.find_images(input_dir),
                           desc="Loading",
                           file=sys.stdout)]
  
          img_list_len = len(img_list)
          for i in tqdm(range(0, img_list_len - 1),
                        desc="Sorting",
                        file=sys.stdout):
              min_score = float("inf")
              j_min_score = i + 1
              for j in range(i + 1, len(img_list)):
                  f1encs = img_list[i][1]
                  f2encs = img_list[j][1]
                  score = self.vgg_face.find_cosine_similiarity(f1encs, f2encs)
                  if score < min_score:
                      min_score = score
                      j_min_score = j
              (img_list[i + 1],
               img_list[j_min_score]) = (img_list[j_min_score],
                                         img_list[i + 1])
          return img_list
  
      def sort_face_dissim(self):
          """ Sort by face dissimilarity """
          input_dir = self.args.input_dir
 
</s> remove 
        img_list = [[img, self.vgg_face.predict(cv2.imread(img)), 0]
                    for img in
                    tqdm(self.find_images(input_dir),
                         desc="Loading",
                         file=sys.stdout)]

        img_list_len = len(img_list)
        for i in tqdm(range(0, img_list_len), desc="Sorting", file=sys.stdout):
            score_total = 0
            for j in range(0, img_list_len):
                if i == j:
                    continue
                score_total += self.vgg_face.find_cosine_similiarity(
                    img_list[i][1],
                    img_list[j][1])

            img_list[i][2] = score_total

        logger.info("Sorting...")
        img_list = sorted(img_list, key=operator.itemgetter(2), reverse=True)
 </s> add         images = np.array(self.find_images(input_dir))
        preds = np.array([self.vgg_face.predict(cv2.imread(img))
                          for img in tqdm(images, desc="loading", file=sys.stdout)])
        logger.info("Sorting. Depending on ths size of your dataset, this may take a while...")
        indices = self.vgg_face.sorted_similarity(preds, method="complete")
        img_list = images[indices] </s> remove             current_image = sorted_list[i][0]
            new_val_index = val_index_list.index(current_image)
            new_list.append([current_image, new_vals_list[new_val_index][1]])
 </s> add             current_img = sorted_list[i] if isinstance(sorted_list[i], str) else sorted_list[i][0]
            new_val_index = val_index_list.index(current_img)
            new_list.append([current_img, new_vals_list[new_val_index][1]]) </s> remove             src = img_list[i][0]
 </s> add             src = img_list[i] if isinstance(img_list[i], str) else img_list[i][0] </s> remove             src, dst = renaming(img_list[i][0], output_dir, i, self.changes)
 </s> add             fname = img_list[i] if isinstance(img_list[i], str) else img_list[i][0]
            src, dst = renaming(fname, output_dir, i, self.changes)
        images = np.array(self.find_images(input_dir))
        preds = np.array([self.vgg_face.predict(cv2.imread(img))
                          for img in tqdm(images, desc="loading", file=sys.stdout)])
        logger.info("Sorting. Depending on ths size of your dataset, this may take a few "
                    "minutes...")
        indices = self.vgg_face.sorted_similarity(preds, method="ward")
        img_list = images[indices]
          input_dir = self.args.input_dir
  
          logger.info("Sorting by face similarity...")
  
        images = np.array(self.find_images(input_dir))
        preds = np.array([self.vgg_face.predict(cv2.imread(img))
                          for img in tqdm(images, desc="loading", file=sys.stdout)])
        logger.info("Sorting. Depending on ths size of your dataset, this may take a few "
                    "minutes...")
        indices = self.vgg_face.sorted_similarity(preds, method="ward")
        img_list = images[indices]
        images = np.array(self.find_images(input_dir))
        preds = np.array([self.vgg_face.predict(cv2.imread(img))
                          for img in tqdm(images, desc="loading", file=sys.stdout)])
        logger.info("Sorting. Depending on ths size of your dataset, this may take a few "
                    "minutes...")
        indices = self.vgg_face.sorted_similarity(preds, method="ward")
        img_list = images[indices]
        images = np.array(self.find_images(input_dir))
        preds = np.array([self.vgg_face.predict(cv2.imread(img))
                          for img in tqdm(images, desc="loading", file=sys.stdout)])
        logger.info("Sorting. Depending on ths size of your dataset, this may take a few "
                    "minutes...")
        indices = self.vgg_face.sorted_similarity(preds, method="ward")
        img_list = images[indices]
        images = np.array(self.find_images(input_dir))
        preds = np.array([self.vgg_face.predict(cv2.imread(img))
                          for img in tqdm(images, desc="loading", file=sys.stdout)])
        logger.info("Sorting. Depending on ths size of your dataset, this may take a few "
                    "minutes...")
        indices = self.vgg_face.sorted_similarity(preds, method="ward")
        img_list = images[indices]
        images = np.array(self.find_images(input_dir))
        preds = np.array([self.vgg_face.predict(cv2.imread(img))
                          for img in tqdm(images, desc="loading", file=sys.stdout)])
        logger.info("Sorting. Depending on ths size of your dataset, this may take a few "
                    "minutes...")
        indices = self.vgg_face.sorted_similarity(preds, method="ward")
        img_list = images[indices]
        images = np.array(self.find_images(input_dir))
        preds = np.array([self.vgg_face.predict(cv2.imread(img))
                          for img in tqdm(images, desc="loading", file=sys.stdout)])
        logger.info("Sorting. Depending on ths size of your dataset, this may take a few "
                    "minutes...")
        indices = self.vgg_face.sorted_similarity(preds, method="ward")
        img_list = images[indices]
        images = np.array(self.find_images(input_dir))
        preds = np.array([self.vgg_face.predict(cv2.imread(img))
                          for img in tqdm(images, desc="loading", file=sys.stdout)])
        logger.info("Sorting. Depending on ths size of your dataset, this may take a few "
                    "minutes...")
        indices = self.vgg_face.sorted_similarity(preds, method="ward")
        img_list = images[indices]
        images = np.array(self.find_images(input_dir))
        preds = np.array([self.vgg_face.predict(cv2.imread(img))
                          for img in tqdm(images, desc="loading", file=sys.stdout)])
        logger.info("Sorting. Depending on ths size of your dataset, this may take a few "
                    "minutes...")
        indices = self.vgg_face.sorted_similarity(preds, method="ward")
        img_list = images[indices]
        images = np.array(self.find_images(input_dir))
        preds = np.array([self.vgg_face.predict(cv2.imread(img))
                          for img in tqdm(images, desc="loading", file=sys.stdout)])
        logger.info("Sorting. Depending on ths size of your dataset, this may take a few "
                    "minutes...")
        indices = self.vgg_face.sorted_similarity(preds, method="ward")
        img_list = images[indices]
        images = np.array(self.find_images(input_dir))
        preds = np.array([self.vgg_face.predict(cv2.imread(img))
                          for img in tqdm(images, desc="loading", file=sys.stdout)])
        logger.info("Sorting. Depending on ths size of your dataset, this may take a few "
                    "minutes...")
        indices = self.vgg_face.sorted_similarity(preds, method="ward")
        img_list = images[indices]
        images = np.array(self.find_images(input_dir))
        preds = np.array([self.vgg_face.predict(cv2.imread(img))
                          for img in tqdm(images, desc="loading", file=sys.stdout)])
        logger.info("Sorting. Depending on ths size of your dataset, this may take a few "
                    "minutes...")
        indices = self.vgg_face.sorted_similarity(preds, method="ward")
        img_list = images[indices]
        images = np.array(self.find_images(input_dir))
        preds = np.array([self.vgg_face.predict(cv2.imread(img))
                          for img in tqdm(images, desc="loading", file=sys.stdout)])
        logger.info("Sorting. Depending on ths size of your dataset, this may take a few "
                    "minutes...")
        indices = self.vgg_face.sorted_similarity(preds, method="ward")
        img_list = images[indices]
        images = np.array(self.find_images(input_dir))
        preds = np.array([self.vgg_face.predict(cv2.imread(img))
                          for img in tqdm(images, desc="loading", file=sys.stdout)])
        logger.info("Sorting. Depending on ths size of your dataset, this may take a few "
                    "minutes...")
        indices = self.vgg_face.sorted_similarity(preds, method="ward")
        img_list = images[indices]
        images = np.array(self.find_images(input_dir))
        preds = np.array([self.vgg_face.predict(cv2.imread(img))
                          for img in tqdm(images, desc="loading", file=sys.stdout)])
        logger.info("Sorting. Depending on ths size of your dataset, this may take a few "
                    "minutes...")
        indices = self.vgg_face.sorted_similarity(preds, method="ward")
        img_list = images[indices]
        images = np.array(self.find_images(input_dir))
        preds = np.array([self.vgg_face.predict(cv2.imread(img))
                          for img in tqdm(images, desc="loading", file=sys.stdout)])
        logger.info("Sorting. Depending on ths size of your dataset, this may take a few "
                    "minutes...")
        indices = self.vgg_face.sorted_similarity(preds, method="ward")
        img_list = images[indices]
        images = np.array(self.find_images(input_dir))
        preds = np.array([self.vgg_face.predict(cv2.imread(img))
                          for img in tqdm(images, desc="loading", file=sys.stdout)])
        logger.info("Sorting. Depending on ths size of your dataset, this may take a few "
                    "minutes...")
        indices = self.vgg_face.sorted_similarity(preds, method="ward")
        img_list = images[indices]
        images = np.array(self.find_images(input_dir))
        preds = np.array([self.vgg_face.predict(cv2.imread(img))
                          for img in tqdm(images, desc="loading", file=sys.stdout)])
        logger.info("Sorting. Depending on ths size of your dataset, this may take a few "
                    "minutes...")
        indices = self.vgg_face.sorted_similarity(preds, method="ward")
        img_list = images[indices]
        images = np.array(self.find_images(input_dir))
        preds = np.array([self.vgg_face.predict(cv2.imread(img))
                          for img in tqdm(images, desc="loading", file=sys.stdout)])
        logger.info("Sorting. Depending on ths size of your dataset, this may take a few "
                    "minutes...")
        indices = self.vgg_face.sorted_similarity(preds, method="ward")
        img_list = images[indices]
        images = np.array(self.find_images(input_dir))
        preds = np.array([self.vgg_face.predict(cv2.imread(img))
                          for img in tqdm(images, desc="loading", file=sys.stdout)])
        logger.info("Sorting. Depending on ths size of your dataset, this may take a few "
                    "minutes...")
        indices = self.vgg_face.sorted_similarity(preds, method="ward")
        img_list = images[indices]
        images = np.array(self.find_images(input_dir))
        preds = np.array([self.vgg_face.predict(cv2.imread(img))
                          for img in tqdm(images, desc="loading", file=sys.stdout)])
        logger.info("Sorting. Depending on ths size of your dataset, this may take a few "
                    "minutes...")
        indices = self.vgg_face.sorted_similarity(preds, method="ward")
        img_list = images[indices]
        images = np.array(self.find_images(input_dir))
        preds = np.array([self.vgg_face.predict(cv2.imread(img))
                          for img in tqdm(images, desc="loading", file=sys.stdout)])
        logger.info("Sorting. Depending on ths size of your dataset, this may take a few "
                    "minutes...")
        indices = self.vgg_face.sorted_similarity(preds, method="ward")
        img_list = images[indices]
        images = np.array(self.find_images(input_dir))
        preds = np.array([self.vgg_face.predict(cv2.imread(img))
                          for img in tqdm(images, desc="loading", file=sys.stdout)])
        logger.info("Sorting. Depending on ths size of your dataset, this may take a few "
                    "minutes...")
        indices = self.vgg_face.sorted_similarity(preds, method="ward")
        img_list = images[indices]
          return img_list
  
      def sort_face_dissim(self):
          """ Sort by face dissimilarity """
          input_dir = self.args.input_dir
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 keep keep keep keep keep
 Sort: Faster sort by face/face-dissim 
tools/sort.py