def pred2box(heatmap, regr, threshold=0.5, scale=4, input_size=512):
    """Convert model output to bounding boxes.

    Args:
        heatmap (np.ndarray): center heatmap, expected matrix with shapes [N, N].
        regr (np.ndarray): width and height coordinates, expected matrix with shapes [2, N, N]
        threshold (float): score threshold.
            If ``None`` then will be ignored filtering.
            Default is ``None``.
        scale (int): output scale, resulting coordinates will be multiplied by that constant.
            Default is ``4``.
        input_size (int): model input size.
            Default is ``512``.

    Returns:
        bounding boxes (np.ndarray with shape [M, 4]) and scores (np.ndarray with shape [M])
    """
    cy, cx = np.where(heatmap > threshold)
    boxes, scores = np.empty((len(cy), 4), dtype=int), np.zeros(len(cx), dtype=float)
    for i, (x, y) in enumerate(zip(cx, cy)):
        scores[i] = heatmap[y, x]
        # x, y in segmentation scales -> upscale outputs
        sx, sy = int(x * scale), int(y * scale)
        w, h = (regr[:, y, x] * input_size).astype(int)
        boxes[i, 0] = sx - w // 2
        boxes[i, 1] = sy - h // 2
        boxes[i, 2] = sx + w // 2
        boxes[i, 3] = sy + h // 2
    return np.array(boxes), np.array(scores)
Convert model output to bounding boxes.

    Args:
        heatmap (np.ndarray): center heatmap, expected matrix with shapes [N, N].
        regr (np.ndarray): width and height coordinates, expected matrix with shapes [2, N, N]
        threshold (float): score threshold.
            If ``None`` then will be ignored filtering.
            Default is ``None``.
        scale (int): output scale, resulting coordinates will be multiplied by that constant.
            Default is ``4``.
        input_size (int): model input size.
            Default is ``512``.

    Returns:
        bounding boxes (np.ndarray with shape [M, 4]) and scores (np.ndarray with shape [M])
    
examples/detection/callbacks.py