{"record":{"id":"947bb0afe79c81f0","repo":"open-mmlab/mmdetection","slug":"metric-item-metric-item-is-not-supported","errorCode":null,"errorMessage":"metric item \"{metric_item}\" is not supported","messagePattern":"metric item \"(.+?)\" is not supported","errorType":"validation","errorClass":"KeyError","httpStatus":null,"severity":"error","filePath":"mmdet/evaluation/metrics/coco_metric.py","lineNumber":498,"sourceCode":"            coco_metric_names = {\n                'mAP': 0,\n                'mAP_50': 1,\n                'mAP_75': 2,\n                'mAP_s': 3,\n                'mAP_m': 4,\n                'mAP_l': 5,\n                'AR@100': 6,\n                'AR@300': 7,\n                'AR@1000': 8,\n                'AR_s@1000': 9,\n                'AR_m@1000': 10,\n                'AR_l@1000': 11\n            }\n            metric_items = self.metric_items\n            if metric_items is not None:\n                for metric_item in metric_items:\n                    if metric_item not in coco_metric_names:\n                        raise KeyError(\n                            f'metric item \"{metric_item}\" is not supported')\n\n            if metric == 'proposal':\n                coco_eval.params.useCats = 0\n                coco_eval.evaluate()\n                coco_eval.accumulate()\n                coco_eval.summarize()\n                if metric_items is None:\n                    metric_items = [\n                        'AR@100', 'AR@300', 'AR@1000', 'AR_s@1000',\n                        'AR_m@1000', 'AR_l@1000'\n                    ]\n\n                for item in metric_items:\n                    val = float(\n                        f'{coco_eval.stats[coco_metric_names[item]]:.3f}')\n                    eval_results[item] = val\n            else:","sourceCodeStart":480,"sourceCodeEnd":516,"githubUrl":"https://github.com/open-mmlab/mmdetection/blob/cfd5d3a985b0249de009b67d04f37263e11cdf3d/mmdet/evaluation/metrics/coco_metric.py#L480-L516","documentation":"CocoMetric.compute_metrics validates user-supplied `metric_items` (specific summary items like 'mAP', 'AP50', 'AR@100') against the fixed coco_metric_names mapping. An item not in that mapping cannot be extracted from the COCOeval stats array, so a KeyError is raised. metric_items only filters which numbers are logged, not which evals run.","triggerScenarios":"Passing CocoMetric(metric='bbox', metric_items=['mAP75','APs','F1']) where 'F1' is not a coco_metric_names key; using lowercase names like 'ap50' instead of 'AP50'; requesting combined names like 'AR@1000' spelled differently from the mapping ('AR_l@1000').","commonSituations":"Trying to log extra derived metrics (F1, recall at custom IoU) that COCOeval does not compute; typo/case mismatch in metric item names copied from a paper or another codebase.","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'","Match the exact spelling/case from coco_metric_names in the source","For custom metrics, subclass CocoMetric and extend compute_metrics instead of metric_items"],"exampleFix":"# before\nmetric_items=['mAP','F1']\n# after\nmetric_items=['mAP','mAP_50','AR@100']","handlingStrategy":"validation","validationCode":"COCO_ITEMS = {'mAP','mAP_50','mAP_75','mAP_s','mAP_m','mAP_l',\n               'AR@100','AR@300','AR@1000','AR_s@1000','AR_m@1000','AR_l@1000'}\nitems = cfg['val_evaluator'].get('metric_items')\nif items:\n    bad = [i for i in items if i not in COCO_ITEMS]\n    assert not bad, f'unsupported metric_items: {bad}'","typeGuard":"def is_supported_metric_item(item: str) -> bool:\n    return item in {'mAP','mAP_50','mAP_75','mAP_s','mAP_m','mAP_l',\n                    'AR@100','AR@300','AR@1000','AR_s@1000','AR_m@1000','AR_l@1000'}","tryCatchPattern":null,"preventionTips":["Copy metric_items names verbatim from coco_metric_names in the source","Case matters: 'AP50' is invalid, 'mAP_50' is correct","Leave metric_items=None to get the default logged set"],"tags":["mmdetection","coco","metric-validation","logging"],"backgroundTag":"invalid-argument-value","analyzedSha":"cfd5d3a985b0249de009b67d04f37263e11cdf3d","analyzedAt":"2026-08-27T20:54:20.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}