clustering
find_pyramid_level(bboxes, base_sizes)
Matches bboxes with pyramid levels given their stride.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bboxes |
ndarray
|
Bbox array with dimension [n, 2] in width-height order. |
required |
base_sizes |
List[int]
|
The basic sizes of anchors in multiple levels. |
required |
Returns:
Type | Description |
---|---|
ndarray
|
Best match per bbox corresponding with index of stride. |
Source code in pyodi/core/clustering.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
|
get_max_overlap(boxes, anchors)
Computes max intersection-over-union between box and anchors.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
boxes |
ndarray
|
Array of bboxes with shape [n, 4]. In corner format. |
required |
anchors |
ndarray
|
Array of bboxes with shape [m, 4]. In corner format. |
required |
Returns:
Type | Description |
---|---|
ndarray
|
Max iou between box and anchors with shape [n, 1]. |
Source code in pyodi/core/clustering.py
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 |
|
kmeans_euclidean(values, n_clusters=3, silhouette_metric=False)
Computes k-means clustering with euclidean distance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
values |
ndarray
|
Data for the k-means algorithm. |
required |
n_clusters |
int
|
Number of clusters. |
3
|
silhouette_metric |
bool
|
Whether to compute the silhouette metric or not. Defaults to False. |
False
|
Returns:
Type | Description |
---|---|
Dict[str, Union[ndarray, float64]]
|
Clustering results. |
Source code in pyodi/core/clustering.py
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 |
|
origin_iou(bboxes, clusters)
Calculates the Intersection over Union (IoU) between a box and k clusters.
Note: COCO format shifted to origin.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bboxes |
ndarray
|
Bboxes array with dimension [n, 2] in width-height order. |
required |
clusters |
ndarray
|
Bbox array with dimension [n, 2] in width-height order. |
required |
Returns:
Type | Description |
---|---|
ndarray
|
BBox array with centroids with dimensions [k, 2]. |
Source code in pyodi/core/clustering.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 |
|