Double Detection Filter¶
Bases: Enum
Enum specifying the strategy for filtering overlapping detections.
Attributes:
Name | Type | Description |
---|---|---|
NONE |
Do not filter detections based on overlap. |
|
NON_MAX_SUPPRESSION |
Filter detections using non-max suppression. This means, detections that overlap by more than a set threshold will be discarded, except for the one with the highest confidence. |
|
NON_MAX_MERGE |
Merge detections with non-max merging. This means, detections that overlap by more than a set threshold will be merged into a single detection. |
Source code in supervision/detection/overlap_filter.py
Perform Non-Maximum Suppression (NMS) on object detection predictions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
ndarray
|
An array of object detection predictions in
the format of |
required |
|
float
|
The intersection-over-union threshold to use for non-maximum suppression. |
0.5
|
Returns:
Type | Description |
---|---|
ndarray
|
np.ndarray: A boolean array indicating which predictions to keep after n on-maximum suppression. |
Raises:
Type | Description |
---|---|
AssertionError
|
If |
Source code in supervision/detection/overlap_filter.py
Perform Non-Maximum Suppression (NMS) on segmentation predictions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
ndarray
|
A 2D array of object detection predictions in
the format of |
required |
|
ndarray
|
A 3D array of binary masks corresponding to the predictions.
Shape: |
required |
|
float
|
The intersection-over-union threshold to use for non-maximum suppression. |
0.5
|
|
int
|
The dimension to which the masks should be resized before computing IOU values. Defaults to 640. |
640
|
Returns:
Type | Description |
---|---|
ndarray
|
np.ndarray: A boolean array indicating which predictions to keep after non-maximum suppression. |
Raises:
Type | Description |
---|---|
AssertionError
|
If |
Source code in supervision/detection/overlap_filter.py
Apply greedy version of non-maximum merging per category to avoid detecting too many overlapping bounding boxes for a given object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
NDArray[float64]
|
An array of shape |
required |
|
float
|
The intersection-over-union threshold to use for non-maximum suppression. Defaults to 0.5. |
0.5
|
Returns:
Type | Description |
---|---|
List[List[int]]
|
List[List[int]]: Groups of prediction indices be merged. Each group may have 1 or more elements. |