core.services.model.evaluator.utils.compute_confusion_matrix¶
compute_confusion_matrix
¶
Functions:
Name | Description |
---|---|
box_iou |
Calculate intersection-over-union (IoU) of boxes. Both sets of boxes are expected to be in (x1, y1, x2, y2) format. |
compute_full_confusion_matrix |
Compute a confusion matrix for object detection with a background class. |
compute_confusion_matrix_impl |
|
box_iou(box1, box2, eps=1e-07)
¶
Calculate intersection-over-union (IoU) of boxes. Both sets of boxes are expected to be in (x1, y1, x2, y2) format. Based on https://github.com/pytorch/vision/blob/master/torchvision/ops/boxes.py.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
Tensor
|
A tensor of shape (N, 4) representing N bounding boxes. |
required |
|
Tensor
|
A tensor of shape (M, 4) representing M bounding boxes. |
required |
|
float
|
A small value to avoid division by zero. Defaults to 1e-7. |
1e-07
|
Returns:
Type | Description |
---|---|
Tensor
|
An NxM tensor containing the pairwise IoU values for every element in box1 and box2. |
compute_full_confusion_matrix(gt_annotations, pred_annotations, label_map, iou_threshold=0.5)
¶
Compute a confusion matrix for object detection with a background class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
List[dict]
|
Ground truth annotations from COCO GT (coco.loadAnns()). |
required |
|
List[dict]
|
Predicted annotations from COCO Pred (coco.loadAnns()). |
required |
|
dict
|
Mapping of category indices (as int) to class names. |
required |
|
float
|
IoU threshold for matching. |
0.5
|
Returns:
Type | Description |
---|---|
ndarray
|
np.ndarray: Confusion matrix of shape (num_classes+1, num_classes+1) where the last index represents 'background'. |