          img_list = list(zip(filename_list, histograms))
  
          logger.info("Comparing histograms and sorting...")
          img_list_len = len(img_list)
          for i in tqdm(range(0, img_list_len - 1), desc="Comparing", file=sys.stdout):
              min_score = float("inf")
              j_min_score = i + 1
              for j in range(i + 1, img_list_len):
                  score = cv2.compareHist(img_list[i][1], img_list[j][1], distance)
                  if score < min_score:
 
</s> remove                 score = cv2.compareHist(img_list[i][1], img_list[j][1], distance)
 </s> add                 score = cv2.compareHist(img_list[i][1], img_list[j][1], cv2.HISTCMP_BHATTACHARYYA) </s> remove         for i in tqdm(range(0, img_list_len - 1), desc="Comparing...", file=sys.stdout):
 </s> add         for i in tqdm(range(0, img_list_len - 1), desc="Comparing", file=sys.stdout): </s> remove         for i in tqdm(range(0, img_list_len - 1), desc="Comparing...", file=sys.stdout):
 </s> add         for i in tqdm(range(0, img_list_len - 1), desc="Comparing", file=sys.stdout): </s> remove         logger.info("Calculating histograms...")
        histograms = [cv2.calcHist([img], [0], None, [256], [0, 256]) for img in image_list]
        img_list = list(zip(filename_list, histograms))
 </s> add         # TODO We have metadata here, so we can mask the face for hist sorting
        img_list = [(filename, cv2.calcHist([image], [0], None, [256], [0, 256]))
                    for filename, image, _ in tqdm(self._loader.load(),
                                                   desc="Calculating histograms",
                                                   total=self._loader.count,
                                                   leave=False)] </s> remove         for i in tqdm(range(0, img_list_len), desc="Comparing", file=sys.stdout):
 </s> add         for i in tqdm(range(0, img_list_len), desc="Comparing histograms", file=sys.stdout):
        for i in tqdm(range(0, img_list_len - 1), desc="Comparing histograms", file=sys.stdout):
          img_list = list(zip(filename_list, histograms))
  
          logger.info("Comparing histograms and sorting...")
          img_list_len = len(img_list)
        for i in tqdm(range(0, img_list_len - 1), desc="Comparing histograms", file=sys.stdout):
              min_score = float("inf")
              j_min_score = i + 1
              for j in range(i + 1, img_list_len):
                  score = cv2.compareHist(img_list[i][1], img_list[j][1], distance)
                  if score < min_score:
keep keep keep keep replace keep keep keep keep keep
 tools.sort
  - Add sort by size
  - Centralize some of the image loading routines 
tools/sort/sort.py