{"record":{"id":"09a9ddb114c8e2ce","repo":"open-mmlab/mmdetection","slug":"metric-metric-is-not-supported-09a9dd","errorCode":null,"errorMessage":"metric {metric} is not supported.","messagePattern":"metric (.+?) is not supported\\.","errorType":"validation","errorClass":"KeyError","httpStatus":null,"severity":"error","filePath":"mmdet/evaluation/metrics/reid_metric.py","lineNumber":46,"sourceCode":"    allowed_metrics = ['mAP', 'CMC']\n    default_prefix: Optional[str] = 'reid-metric'\n\n    def __init__(self,\n                 metric: Union[str, Sequence[str]] = 'mAP',\n                 metric_options: Optional[dict] = None,\n                 collect_device: str = 'cpu',\n                 prefix: Optional[str] = None) -> None:\n        super().__init__(collect_device, prefix)\n\n        if isinstance(metric, list):\n            metrics = metric\n        elif isinstance(metric, str):\n            metrics = [metric]\n        else:\n            raise TypeError('metric must be a list or a str.')\n        for metric in metrics:\n            if metric not in self.allowed_metrics:\n                raise KeyError(f'metric {metric} is not supported.')\n        self.metrics = metrics\n\n        self.metric_options = metric_options or dict(\n            rank_list=[1, 5, 10, 20], max_rank=20)\n        for rank in self.metric_options['rank_list']:\n            assert 1 <= rank <= self.metric_options['max_rank']\n\n    def process(self, data_batch: dict, data_samples: Sequence[dict]) -> None:\n        \"\"\"Process one batch of data samples and predictions.\n\n        The processed results should be stored in ``self.results``, which will\n        be used to compute the metrics when all batches have been processed.\n\n        Args:\n            data_batch (dict): A batch of data from the dataloader.\n            data_samples (Sequence[dict]): A batch of data samples that\n                contain annotations and predictions.\n        \"\"\"","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/open-mmlab/mmdetection/blob/cfd5d3a985b0249de009b67d04f37263e11cdf3d/mmdet/evaluation/metrics/reid_metric.py#L28-L64","documentation":"ReIDMetrics supports only its allowed_metrics set (currently ['mAP', 'CMC'], plus 'tCMC' in some versions); any other metric name raises this KeyError. The check runs per item after the type check on the metric argument.","triggerScenarios":"Passing metric=['top1', 'recall@k', 'R1'] or a misspelled 'MAP'/'map' (case-sensitive) to ReIDMetrics.","commonSituations":"Porting metric names from other ReID codebases (torchreid uses 'rank-1', 'mAP'); assuming case-insensitive names; using metric names from newer mmdet versions on older installs.","solutions":["Use only supported names: 'mAP' and 'CMC' (and 'tCMC' where available) with exact casing","Check ReIDMetrics.allowed_metrics in your installed mmdet version for the definitive list","Upgrade mmdet if you need an additional metric that exists only in newer versions"],"exampleFix":"# before\nval_evaluator = dict(type='ReIDMetrics', metric=['mAP', 'R1'])\n# after\nval_evaluator = dict(type='ReIDMetrics', metric=['mAP', 'CMC'])","handlingStrategy":"validation","validationCode":"from mmdet.evaluation.metrics.reid_metric import ReIDMetrics\nbad = set(metric_list) - set(ReIDMetrics.allowed_metrics)\nassert not bad, f'unsupported ReID metrics: {bad}'","typeGuard":"def is_supported_reid_metric(metric) -> bool:\n    return metric in getattr(ReIDMetrics, 'allowed_metrics', {'mAP', 'CMC'})","tryCatchPattern":"try:\n    m = ReIDMetrics(metric=metric)\nexcept KeyError as e:\n    raise ValueError(f'use only {ReIDMetrics.allowed_metrics}: {e}') from e","preventionTips":["Use exact casing 'mAP' and 'CMC'","Check allowed_metrics attribute at runtime","Don't port metric names from torchreid directly"],"tags":["mmdet","reid","unsupported-metric","config"],"backgroundTag":null,"analyzedSha":"cfd5d3a985b0249de009b67d04f37263e11cdf3d","analyzedAt":"2026-08-27T20:54:20.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}