Skip to content

nextcv.postprocessing.boxes ⚓︎

Bounding box postprocessing functions.

FUNCTION DESCRIPTION
iou_np

Calculate intersection over union of target box with all others.

nms_cpp

Non-Maximum-Supression (NMS) algorithm to remove overlapping bounding boxes.

nms_np

Non-Maximum-Supression (NMS) algorithm to remove overlapping bounding boxes.

wbf_cpp

Fuse detections from multiple models using Weighted Box Fusion (WBF).

wbf_np

Reference WBF implementation from ensemble_boxes package.

nextcv.postprocessing.boxes.iou_np ⚓︎

iou_np(target_box: NDArray, boxes: NDArray, target_area: NDArray, areas: NDArray, inclusive: bool = False) -> NDArray

Calculate intersection over union of target box with all others.

PARAMETER DESCRIPTION
target_box

The bounding box as (top_left_x, top_left_y, bottom_right_x, bottom_right_y).

TYPE: NDArray

boxes

The bounding boxes as (top_left_x, top_left_y, bottom_right_x, bottom_right_y).

TYPE: NDArray

target_area

The area of the target box.

TYPE: NDArray

areas

The areas of all boxes.

TYPE: NDArray

inclusive

If True, uses (x2 - x1 + 1) * (y2 - y1 + 1) for area. Enable only for integer, pixel-indexed boxes (VOC/OpenCV style).

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
NDArray

The intersection over union of the target box with all others.

nextcv.postprocessing.boxes.nms_cpp ⚓︎

nms_cpp(bboxes: NDArray, scores: NDArray, iou_thresh: float) -> NDArray[int32]

Non-Maximum-Supression (NMS) algorithm to remove overlapping bounding boxes.

PARAMETER DESCRIPTION
bboxes

The bounding boxes as (top_left_x, top_left_y, bottom_right_x, bottom_right_y).

TYPE: NDArray

scores

The confidence scores for each bounding box.

TYPE: NDArray

iou_thresh

The threshold for intersection over union.

TYPE: float

nextcv.postprocessing.boxes.nms_np ⚓︎

nms_np(bboxes: NDArray, scores: NDArray, iou_thresh: float) -> NDArray

Non-Maximum-Supression (NMS) algorithm to remove overlapping bounding boxes.

PARAMETER DESCRIPTION
bboxes

The bounding boxes as (top_left_x, top_left_y, bottom_right_x, bottom_right_y).

TYPE: NDArray

scores

The confidence scores for each bounding box.

TYPE: NDArray

iou_thresh

The threshold for intersection over union.

TYPE: float

RETURNS DESCRIPTION
NDArray

The indices of the bounding boxes to keep.

nextcv.postprocessing.boxes.wbf_cpp ⚓︎

wbf_cpp(boxes_list: list[NDArray], scores_list: list[NDArray], labels_list: list[NDArray], weights: list[float] | None = None, iou_thr: float = 0.55, skip_box_thr: float = 0.0, conf_type: str = 'avg', allows_overflow: bool = False) -> tuple[NDArray[float32], NDArray[float32], NDArray[int32]]

Fuse detections from multiple models using Weighted Box Fusion (WBF).

PARAMETER DESCRIPTION
boxes_list

Per-model boxes with shape (N_i, 4) in normalized xyxy format.

TYPE: list[NDArray]

scores_list

Per-model confidence scores with shape (N_i,).

TYPE: list[NDArray]

labels_list

Per-model integer labels with shape (N_i,).

TYPE: list[NDArray]

weights

Optional per-model weights. Defaults to equal weights.

TYPE: list[float] | None DEFAULT: None

iou_thr

IoU threshold for clustering boxes into the same fused box.

TYPE: float DEFAULT: 0.55

skip_box_thr

Drop boxes with score lower than this threshold.

TYPE: float DEFAULT: 0.0

conf_type

Confidence mode. One of: "avg", "max", "box_and_model_avg", "absent_model_aware_avg".

TYPE: str DEFAULT: 'avg'

allows_overflow

If True, confidence can exceed 1.0 for avg mode.

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
tuple[NDArray[float32], NDArray[float32], NDArray[int32]]

Tuple of (fused_boxes, fused_scores, fused_labels).

nextcv.postprocessing.boxes.wbf_np ⚓︎

wbf_np(boxes_list: list[NDArray], scores_list: list[NDArray], labels_list: list[NDArray], **kwargs: object) -> tuple[NDArray[float32], NDArray[float32], NDArray[int32]]

Reference WBF implementation from ensemble_boxes package.