ocl.metrics.bbox
Metrics related to the evaluation of bounding boxes.
UnsupervisedBboxIoUMetric
Bases: torchmetrics.Metric
Computes IoU metric for bounding boxes when correspondences to ground truth are not known.
Currently, assumes segmentation masks as input for both prediction and targets.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target_is_mask |
bool
|
If |
False
|
use_threshold |
bool
|
If |
False
|
threshold |
float
|
Value to use for thresholding masks. |
0.5
|
matching |
str
|
How to match predicted boxes to ground truth boxes. For "hungarian", computes assignment that maximizes total IoU between all boxes. For "best_overlap", uses the predicted box with maximum overlap for each ground truth box (each predicted box can be assigned to multiple ground truth boxes). |
'hungarian'
|
compute_discovery_fraction |
bool
|
Instead of the IoU, compute the fraction of ground truth classes that were "discovered", meaning that they have an IoU greater than some threshold. This is recall, or sometimes called the detection rate metric. |
False
|
correct_localization |
bool
|
Instead of the IoU, compute the fraction of images on which at least one ground truth bounding box was correctly localised, meaning that they have an IoU greater than some threshold. |
False
|
discovery_threshold |
float
|
Minimum IoU to count a class as discovered/correctly localized. |
0.5
|
Source code in ocl/metrics/bbox.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
|
update
Update this metric.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prediction |
torch.Tensor
|
Predicted mask of shape (B, C, H, W) or (B, F, C, H, W), where C is the number of instances. Assumes class probabilities as inputs. |
required |
target |
torch.Tensor
|
Ground truth mask of shape (B, K, H, W) or (B, F, K, H, W), where K is the number of instance, if using masks as input, or bounding boxes of shape (B, K, 4) or (B, F, K, 4). |
required |
Source code in ocl/metrics/bbox.py
unsupervised_bbox_iou
Compute IoU between two sets of bounding boxes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pred_bboxes |
torch.Tensor
|
Predicted bounding boxes of shape N x 4. |
required |
true_bboxes |
torch.Tensor
|
True bounding boxes of shape M x 4. |
required |
matching |
str
|
Method to assign predicted to true bounding boxes. |
'best_overlap'
|
reduction |
str
|
Whether to average the computes IoUs per true box. |
'mean'
|