Esempio n. 1
0
 def synchronize_between_processes(self):
     if self.fixed_ap:
         all_cats = dist.all_gather(self.by_cat)
         self.by_cat = defaultdict(list)
         for cats in all_cats:
             for cat, cat_anns in cats.items():
                 self.by_cat[cat].extend(cat_anns)
     else:
         self.results = sum(dist.all_gather(self.results), [])
Esempio n. 2
0
def merge(img_ids, eval_imgs):
    all_img_ids = all_gather(img_ids)
    all_eval_imgs = all_gather(eval_imgs)

    merged_img_ids = []
    for p in all_img_ids:
        merged_img_ids.extend(p)

    merged_eval_imgs = []
    for p in all_eval_imgs:
        merged_eval_imgs.append(p)

    merged_img_ids = np.array(merged_img_ids)
    merged_eval_imgs = np.concatenate(merged_eval_imgs, 2)

    # keep only unique (and in sorted order) images
    merged_img_ids, idx = np.unique(merged_img_ids, return_index=True)
    merged_eval_imgs = merged_eval_imgs[..., idx]

    return merged_img_ids, merged_eval_imgs
Esempio n. 3
0
 def synchronize_between_processes(self):
     all_predictions = dist.all_gather(self.predictions)
     merged_predictions = {}
     for p in all_predictions:
         merged_predictions.update(p)
     self.predictions = merged_predictions
Esempio n. 4
0
 def synchronize_between_processes(self):
     all_predictions = dist.all_gather(self.predictions)
     merged_predictions = []
     for p in all_predictions:
         merged_predictions += p
     self.predictions = merged_predictions
Esempio n. 5
0
 def synchronize_between_processes(self):
     all_predictions = dist.all_gather(self.predictions)
     self.predictions = sum(all_predictions, [])
     self.predictions = sorted(self.predictions,
                               key=lambda x: x["questionId"])
     self.predictions = [p["prediction"] for p in self.predictions]
Esempio n. 6
0
 def synchronize_between_processes(self):
     all_predictions = dist.all_gather(self.predictions)
     self.predictions = sum(all_predictions, [])