vis4d.eval.coco.detect

COCO evaluator.

Functions

predictions_to_coco(cat_map, coco_id2name, ...)

Convert Vis4D format predictions to COCO format.

xyxy_to_xywh(boxes)

Convert Tensor [N, 4] in xyxy format into xywh.

Classes

COCODetectEvaluator(data_root[, split, ...])

COCO detection evaluation class.

COCOevalV2([cocoGt, cocoDt, iouType])

Subclass COCO eval for logging / printing.

class COCODetectEvaluator(data_root, split='val2017', per_class_eval=False)[source]

COCO detection evaluation class.

Creates an instance of the class.

Parameters:
  • data_root (str) – Root directory of data.

  • split (str, optional) – COCO data split. Defaults to “val2017”.

  • per_class_eval (bool, optional) – Per-class evaluation. Defaults to False.

__repr__()[source]

Returns the string representation of the object.

Return type:

str

evaluate(metric)[source]

Evaluate COCO predictions.

Parameters:

metric (str) – Metric to evaluate. Should be “COCO_AP”.

Raises:
  • NotImplementedError – Raised if metric is not “COCO_AP”.

  • RuntimeError – Raised if no predictions are available.

Returns:

Dictionary of scores to log and a pretty

printed string.

Return type:

tuple[MetricLogs, str]

gather(gather_func)[source]

Accumulate predictions across processes.

Return type:

None

process_batch(coco_image_id, pred_boxes, pred_scores, pred_classes, pred_masks=None)[source]

Process sample and convert detections to coco format.

coco_image_id (list[int]): COCO image ID. pred_boxes (list[NDArrayNumber]): Predicted bounding boxes. pred_scores (list[NDArrayNumber]): Predicted scores for each box. pred_classes (list[NDArrayNumber]): Predicted classes for each box. pred_masks (None | list[NDArrayNumber], optional): Predicted masks.

Return type:

None

reset()[source]

Reset the saved predictions to start new round of evaluation.

Return type:

None

property metrics: list[str]

Supported metrics.

Returns:

Metrics to evaluate.

Return type:

list[str]

class COCOevalV2(cocoGt=None, cocoDt=None, iouType='segm')[source]

Subclass COCO eval for logging / printing.

Initialize CocoEval using coco APIs for gt and dt :type cocoGt: :param cocoGt: coco object with ground truth annotations :type cocoDt: :param cocoDt: coco object with detection results :return: None

summarize()[source]

Capture summary in string.

Returns:

Pretty printed string.

Return type:

str

predictions_to_coco(cat_map, coco_id2name, image_id, boxes, scores, classes, masks=None)[source]

Convert Vis4D format predictions to COCO format.

Parameters:
  • cat_map (dict[str, int]) – COCO class name to class ID mapping.

  • coco_id2name (dict[int, str]) – COCO class ID to class name mapping.

  • image_id (int) – ID of image.

  • boxes (NDArrayNumber) – Predicted bounding boxes.

  • scores (NDArrayNumber) – Predicted scores for each box.

  • classes (NDArrayNumber) – Predicted classes for each box.

  • masks (None | NDArrayNumber, optional) – Predicted masks. Defaults to None.

Returns:

Predictions in COCO format.

Return type:

list[DictStrAny]

xyxy_to_xywh(boxes)[source]

Convert Tensor [N, 4] in xyxy format into xywh.

Parameters:

boxes (NDArrayNumber) – Bounding boxes in Vis4D format.

Returns:

COCO format bounding boxes.

Return type:

NDArrayNumber