open-mmlab/mmdetection · error · ValueError

Unrecognized mode, only "area" and "11points" are supported

Error message

Unrecognized mode, only "area" and "11points" are supported

What it means

average_precision supports only two computation modes: 'area' (COCO-style interpolation) and '11points' (VOC-style 11-point interpolation). Any other mode string raises ValueError.

Solutions

  1. Use exactly 'area' or '11points'
  2. Check config files for misspelled eval mode keys (e.g. '11point' -> '11points')

Example fix

# before
eval_map(det, gt, mode='11point')
# after
eval_map(det, gt, mode='11points')
Defensive patterns

Strategy: validation

Validate before calling

assert mode in ('area', '11points'), f'bad mode: {mode}'

Type guard

def is_valid_ap_mode(m: str) -> bool:
    return m in ('area', '11points')

Prevention

When it happens

Trigger: Calling eval_map/average_precision with mode='11point', mode='max', or a typo like 'Arae'.

Common situations: Porting VOC configs where the flag is written '11point' (single point) instead of '11points'; custom eval scripts passing arbitrary mode strings.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of open-mmlab/mmdetection@cfd5d3a985 (2026-08-27). Data as JSON: /api/errors/2477fba5f9aab7e1. Report an issue: GitHub.

Appendix: source

Thrown at mmdet/evaluation/functional/mean_ap.py:53

        zeros = np.zeros((num_scales, 1), dtype=recalls.dtype)
        ones = np.ones((num_scales, 1), dtype=recalls.dtype)
        mrec = np.hstack((zeros, recalls, ones))
        mpre = np.hstack((zeros, precisions, zeros))
        for i in range(mpre.shape[1] - 1, 0, -1):
            mpre[:, i - 1] = np.maximum(mpre[:, i - 1], mpre[:, i])
        for i in range(num_scales):
            ind = np.where(mrec[i, 1:] != mrec[i, :-1])[0]
            ap[i] = np.sum(
                (mrec[i, ind + 1] - mrec[i, ind]) * mpre[i, ind + 1])
    elif mode == '11points':
        for i in range(num_scales):
            for thr in np.arange(0, 1 + 1e-3, 0.1):
                precs = precisions[i, recalls[i, :] >= thr]
                prec = precs.max() if precs.size > 0 else 0
                ap[i] += prec
        ap /= 11
    else:
        raise ValueError(
            'Unrecognized mode, only "area" and "11points" are supported')
    if no_scale:
        ap = ap[0]
    return ap


def tpfp_imagenet(det_bboxes,
                  gt_bboxes,
                  gt_bboxes_ignore=None,
                  default_iou_thr=0.5,
                  area_ranges=None,
                  use_legacy_coordinate=False,
                  **kwargs):
    """Check if detected bboxes are true positive or false positive.

    Args:
        det_bbox (ndarray): Detected bboxes of this image, of shape (m, 5).
        gt_bboxes (ndarray): GT bboxes of this image, of shape (n, 4).

View on GitHub (pinned to cfd5d3a985)