open-mmlab/mmdetection · error · KeyError
metric item "{metric_item}" is not supported
Error message
metric item "{metric_item}" is not supported What it means
OV-COCOMetric validates self.metric_items against the fixed set of coco_metric_names keys (mAP, mAP_50, ..., AR_l@1000). Any item not in that table raises this KeyError, because the metric cannot compute an unknown statistic.
Source
Thrown at mmdet/evaluation/metrics/ov_coco_metric.py:138
coco_metric_names = {
'mAP': 0,
'mAP_50': 1,
'mAP_75': 2,
'mAP_s': 3,
'mAP_m': 4,
'mAP_l': 5,
'AR@100': 6,
'AR@300': 7,
'AR@1000': 8,
'AR_s@1000': 9,
'AR_m@1000': 10,
'AR_l@1000': 11
}
metric_items = self.metric_items
if metric_items is not None:
for metric_item in metric_items:
if metric_item not in coco_metric_names:
raise KeyError(
f'metric item "{metric_item}" is not supported')
if metric == 'proposal':
coco_eval.params.useCats = 0
coco_eval.evaluate()
coco_eval.accumulate()
coco_eval.summarize()
if metric_items is None:
metric_items = [
'AR@100', 'AR@300', 'AR@1000', 'AR_s@1000',
'AR_m@1000', 'AR_l@1000'
]
for item in metric_items:
val = float(
f'{coco_eval.stats[coco_metric_names[item]]:.3f}')
eval_results[item] = val
else:View on GitHub (pinned to cfd5d3a985)
Solutions
- Use only supported items: mAP, mAP_50, mAP_75, mAP_s, mAP_m, mAP_l, AR@100, AR@300, AR@1000, AR_s@1000, AR_m@1000, AR_l@1000
- Leave metric_items=None to get the default set (mAP, mAP_50, mAP_75, mAP_s, mAP_m, mAP_l)
- Check the coco_metric_names dict in the source for the exact accepted keys of your mmdet version
Example fix
# before val_evaluator = dict(type='OVCocoMetric', metric='bbox', metric_items=['AP50', 'AP75']) # after val_evaluator = dict(type='OVCocoMetric', metric='bbox', metric_items=['mAP_50', 'mAP_75'])
Defensive patterns
Strategy: validation
Validate before calling
SUPPORTED = {'mAP','mAP_50','mAP_75','mAP_s','mAP_m','mAP_l','AR@100','AR@300','AR@1000','AR_s@1000','AR_m@1000','AR_l@1000'}
bad = set(metric_items or []) - SUPPORTED
assert not bad, f'unsupported metric_items: {bad}' Type guard
def is_valid_metric_items(items) -> bool:
SUPPORTED = {'mAP','mAP_50','mAP_75','mAP_s','mAP_m','mAP_l','AR@100','AR@300','AR@1000','AR_s@1000','AR_m@1000','AR_l@1000'}
return items is None or all(i in SUPPORTED for i in items) Try / catch
try:
evaluator.evaluate(results)
except KeyError as e:
raise ValueError(f'fix metric_items in config: {e}') from e Prevention
- Copy metric_items from official mmdet COCO configs
- Leave metric_items unset for the defaults
- Check coco_metric_names keys in the installed version
When it happens
Trigger: Passing metric_items=['mAP@0.5:0.95', 'AP50', 'AR@100'] or other non-standard names to OVCocoMetric; misspelling a supported item like 'mAP_50'.
Common situations: Copy-pasting metric_items strings from pycocotools logs or papers instead of the supported keys; version changes renaming items; mixing Pascal VOC item names into a COCO evaluator.
Related errors
- {metric} is not in results
- metric item "{metric_item}" is not supported
- batch_size should be a positive integer value, but got batch
- img_border_value must be float or tuple with 3 elements.
- metric must be a list or a str.
AI-assisted analysis of open-mmlab/mmdetection@cfd5d3a985 (2026-08-27).
Data as JSON: /api/errors/c153a5d9d1ebf84f.
Report an issue: GitHub.