def create_coco_eval( records, preds, metric_type: str, iou_thresholds: Optional[Sequence[float]] = None, show_pbar: bool = False, ) -> COCOeval: assert len(records) == len(preds) for record, pred in zip(records, preds): pred.record_id = record.record_id pred.height = record.height pred.width = record.width # needs 'filepath' for mask `coco.py#418` pred.filepath = record.filepath target_ds = coco_api_from_records(records, show_pbar=show_pbar) pred_ds = coco_api_from_preds(preds, show_pbar=show_pbar) coco_eval = COCOeval(target_ds, pred_ds, metric_type) if iou_thresholds is not None: coco_eval.iouThrs = iou_thresholds return coco_eval