def decode_netout(netout, anchors, obj_thresh, nms_thresh, net_h, net_w):
    (grid_h, grid_w) = netout.shape[:2]
    nb_box = 3
    netout = netout.reshape((grid_h, grid_w, nb_box, (- 1)))
    nb_class = (netout.shape[(- 1)] - 5)
    boxes = []
    netout[..., :2] = _sigmoid(netout[..., :2])
    netout[..., 4:] = _sigmoid(netout[..., 4:])
    netout[..., 5:] = (netout[(..., 4)][(..., np.newaxis)] * netout[..., 5:])
    netout[..., 5:] *= (netout[..., 5:] > obj_thresh)
    for i in range((grid_h * grid_w)):
        row = (i / grid_w)
        col = (i % grid_w)
        for b in range(nb_box):
            objectness = netout[int(row)][int(col)][b][4]
            if (objectness.all() <= obj_thresh):
                continue
            (x, y, w, h) = netout[int(row)][int(col)][b][:4]
            x = ((col + x) / grid_w)
            y = ((row + y) / grid_h)
            w = ((anchors[((2 * b) + 0)] * np.exp(w)) / net_w)
            h = ((anchors[((2 * b) + 1)] * np.exp(h)) / net_h)
            classes = netout[int(row)][col][b][5:]
            box = BoundBox((x - (w / 2)), (y - (h / 2)), (x + (w / 2)), (y + (h / 2)), objectness, classes)
            boxes.append(box)
    return boxes
def decode_netout(netout, anchors, obj_thresh, nms_thresh, net_h, net_w):
    (grid_h, grid_w) = netout.shape[:2]
    nb_box = 3
    netout = netout.reshape((grid_h, grid_w, nb_box, (- 1)))
    nb_class = (netout.shape[(- 1)] - 5)
    boxes = []
    netout[..., :2] = _sigmoid(netout[..., :2])
    netout[..., 4:] = _sigmoid(netout[..., 4:])
    netout[..., 5:] = (netout[(..., 4)][(..., np.newaxis)] * netout[..., 5:])
    netout[..., 5:] *= (netout[..., 5:] > obj_thresh)
    for i in range((grid_h * grid_w)):
        row = (i / grid_w)
        col = (i % grid_w)
        for b in range(nb_box):
            objectness = netout[int(row)][int(col)][b][4]
            if (objectness.all() <= obj_thresh):
                continue
            (x, y, w, h) = netout[int(row)][int(col)][b][:4]
            x = ((col + x) / grid_w)
            y = ((row + y) / grid_h)
            w = ((anchors[((2 * b) + 0)] * np.exp(w)) / net_w)
            h = ((anchors[((2 * b) + 1)] * np.exp(h)) / net_h)
            classes = netout[int(row)][col][b][5:]
            box = BoundBox((x - (w / 2)), (y - (h / 2)), (x + (w / 2)), (y + (h / 2)), objectness, classes)
            boxes.append(box)
    return boxes