def voc_ap(rec, prec, use_07_metric=True):
    ' ap = voc_ap(rec, prec, [use_07_metric])\n    Compute VOC AP given precision and recall.\n    If use_07_metric is true, uses the\n    VOC 07 11 point method (default:True).\n    '
    if use_07_metric:
        ap = 0.0
        for t in np.arange(0.0, 1.1, 0.1):
            if (np.sum((rec >= t)) == 0):
                p = 0
            else:
                p = np.max(prec[(rec >= t)])
            ap = (ap + (p / 11.0))
    else:
        mrec = np.concatenate(([0.0], rec, [1.0]))
        mpre = np.concatenate(([0.0], prec, [0.0]))
        for i in range((mpre.size - 1), 0, (- 1)):
            mpre[(i - 1)] = np.maximum(mpre[(i - 1)], mpre[i])
        i = np.where((mrec[1:] != mrec[:(- 1)]))[0]
        ap = np.sum(((mrec[(i + 1)] - mrec[i]) * mpre[(i + 1)]))
    return ap
ap = voc_ap(rec, prec, [use_07_metric])
Compute VOC AP given precision and recall.
If use_07_metric is true, uses the
VOC 07 11 point method (default:True).
def voc_ap(rec, prec, use_07_metric=True):
    ' ap = voc_ap(rec, prec, [use_07_metric])\n    Compute VOC AP given precision and recall.\n    If use_07_metric is true, uses the\n    VOC 07 11 point method (default:True).\n    '
    if use_07_metric:
        ap = 0.0
        for t in np.arange(0.0, 1.1, 0.1):
            if (np.sum((rec >= t)) == 0):
                p = 0
            else:
                p = np.max(prec[(rec >= t)])
            ap = (ap + (p / 11.0))
    else:
        mrec = np.concatenate(([0.0], rec, [1.0]))
        mpre = np.concatenate(([0.0], prec, [0.0]))
        for i in range((mpre.size - 1), 0, (- 1)):
            mpre[(i - 1)] = np.maximum(mpre[(i - 1)], mpre[i])
        i = np.where((mrec[1:] != mrec[:(- 1)]))[0]
        ap = np.sum(((mrec[(i + 1)] - mrec[i]) * mpre[(i + 1)]))
    return ap