def nms_filter(bboxes, classes, confidences, iou_threshold=0.5):
    """Filter classes, bboxes, confidences by nms with iou_threshold.

    Args:
        bboxes (np.ndarray): array with bounding boxes, expected shape [N, 4].
        classes (np.ndarray): array with classes, expected shape [N].
        confidences (np.ndarray): array with class confidence, expected shape [N].
        iou_threshold (float): IoU threshold to use for filtering.
            Default is ``0.5``.

    Returns:
        filtered bboxes (np.ndarray), classes (np.ndarray), and confidences (np.ndarray)
            where number of records will be equal to some M (M <= N).
    """
    keep_bboxes = []
    keep_classes = []
    keep_confidences = []

    for presented_cls in np.unique(classes):
        mask = classes == presented_cls
        curr_bboxes = bboxes[mask, :]
        curr_classes = classes[mask]
        curr_confs = confidences[mask]

        to_keep = box_nms(curr_bboxes, curr_confs, iou_threshold)

        keep_bboxes.append(curr_bboxes[to_keep, :])
        keep_classes.append(curr_classes[to_keep])
        keep_confidences.append(curr_confs[to_keep])

    return (
        np.concatenate(keep_bboxes),
        np.concatenate(keep_classes),
        np.concatenate(keep_confidences),
    )
Filter classes, bboxes, confidences by nms with iou_threshold.

    Args:
        bboxes (np.ndarray): array with bounding boxes, expected shape [N, 4].
        classes (np.ndarray): array with classes, expected shape [N].
        confidences (np.ndarray): array with class confidence, expected shape [N].
        iou_threshold (float): IoU threshold to use for filtering.
            Default is ``0.5``.

    Returns:
        filtered bboxes (np.ndarray), classes (np.ndarray), and confidences (np.ndarray)
            where number of records will be equal to some M (M <= N).
    
examples/detection/utils.py