  
          logger.info("Finding landmarks in images...")
          # TODO thread the put to queue so we don't have to put and get at the same time
          # Or even better, set up a proper background loader from disk (i.e. use lib.image.ImageIO)
          for idx, feed in enumerate(tqdm(feed_list, desc="Aligning...", file=sys.stdout)):
              extractor.input_queue.put(feed)
              landmarks[idx] = next(extractor.detected_faces()).detected_faces[0].landmarks_xy
  
          return filename_list, image_list, landmarks
  
 
</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         logger.info("Calculating histograms...")
        histograms = [cv2.calcHist([img], [0], None, [256], [0, 256]) for img in image_list]
        img_list = list(list(items) for items in zip(filename_list, histograms, scores))
 </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]), 0.0]
                    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 - 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         # TODO set this as FacesLoader in init. Need to move all processes to use it
        self._loader = None
 </s> add         self._loader = FacesLoader(self._args.input_dir)
        for idx, feed in enumerate(tqdm(feed_list, desc="Aligning", file=sys.stdout)):
  
          logger.info("Finding landmarks in images...")
          # TODO thread the put to queue so we don't have to put and get at the same time
          # Or even better, set up a proper background loader from disk (i.e. use lib.image.ImageIO)
        for idx, feed in enumerate(tqdm(feed_list, desc="Aligning", file=sys.stdout)):
              extractor.input_queue.put(feed)
              landmarks[idx] = next(extractor.detected_faces()).detected_faces[0].landmarks_xy
  
          return filename_list, image_list, landmarks
  
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