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.

xyxy_to_xywh(boxes)[source]

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

Parameters:

boxes (NDArrayF32) – Bounding boxes in Vis4D format.

Returns:

COCO format bounding boxes.

Return type:

NDArrayF32

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

Subclass COCO eval for logging / printing.

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 (NDArrayF32) – Predicted bounding boxes.

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

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

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

Returns:

Predictions in COCO format.

Return type:

list[DictStrAny]

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

COCO detection evaluation class.

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

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.

property metrics: list[str]

Supported metrics.

Returns:

Metrics to evaluate.

Return type:

list[str]

gather(gather_func)[source]

Accumulate predictions across processes.

Return type:

None

reset()[source]

Reset the saved predictions to start new round of evaluation.

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[ArrayLike]): Predicted bounding boxes. pred_scores (list[ArrayLike]): Predicted scores for each box. pred_classes (list[ArrayLike]): Predicted classes for each box. pred_masks (None | list[ArrayLike], optional): Predicted masks.

Return type:

None

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]

__repr__()[source]

Returns the string representation of the object.

Return type:

str