{"record":{"id":"a2621a524503aeeb","repo":"open-mmlab/mmdetection","slug":"metric-is-not-in-results-a2621a","errorCode":null,"errorMessage":"{metric} is not in results","messagePattern":"(.+?) is not in results","errorType":"validation","errorClass":"KeyError","httpStatus":null,"severity":"error","filePath":"mmdet/evaluation/metrics/ov_coco_metric.py","lineNumber":90,"sourceCode":"            logger.info(f'Evaluating {metric}...')\n\n            # TODO: May refactor fast_eval_recall to an independent metric?\n            # fast eval recall\n            if metric == 'proposal_fast':\n                ar = self.fast_eval_recall(\n                    preds, self.proposal_nums, self.iou_thrs, logger=logger)\n                log_msg = []\n                for i, num in enumerate(self.proposal_nums):\n                    eval_results[f'AR@{num}'] = ar[i]\n                    log_msg.append(f'\\nAR@{num}\\t{ar[i]:.4f}')\n                log_msg = ''.join(log_msg)\n                logger.info(log_msg)\n                continue\n\n            # evaluate proposal, bbox and segm\n            iou_type = 'bbox' if metric == 'proposal' else metric\n            if metric not in result_files:\n                raise KeyError(f'{metric} is not in results')\n            try:\n                predictions = load(result_files[metric])\n                if iou_type == 'segm':\n                    # Refer to https://github.com/cocodataset/cocoapi/blob/master/PythonAPI/pycocotools/coco.py#L331  # noqa\n                    # When evaluating mask AP, if the results contain bbox,\n                    # cocoapi will use the box area instead of the mask area\n                    # for calculating the instance area. Though the overall AP\n                    # is not affected, this leads to different\n                    # small/medium/large mask AP results.\n                    for x in predictions:\n                        x.pop('bbox')\n                coco_dt = self._coco_api.loadRes(predictions)\n\n            except IndexError:\n                logger.error(\n                    'The testing results of the whole dataset is empty.')\n                break\n","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/open-mmlab/mmdetection/blob/cfd5d3a985b0249de009b67d04f37263e11cdf3d/mmdet/evaluation/metrics/ov_coco_metric.py#L72-L108","documentation":"Thrown by OV-COCOMetric.compute_metrics when the requested metric name (e.g. 'bbox', 'segm', 'proposal') has no corresponding entry in result_files, meaning results for that prediction type were never produced during evaluation. It signals a mismatch between the metrics configured on the metric object and the prediction formats actually accumulated by the model/dataset pipeline.","triggerScenarios":"Calling compute_metrics (or engine.train()/test()) with metric=['bbox','segm'] when the model only outputs one prediction type, or when format_only=True skips generating a results file for a requested metric; also when results2json-style conversion omits a key for the configured metric.","commonSituations":"Configuring OpenVocabCocoMetric with 'segm' for a detection-only (no mask) model; using a test pipeline that drops mask predictions; copy-pasting a COCO instance-seg config for a bbox-only model.","solutions":["Ensure the model actually produces predictions of the type requested (add mask head for 'segm', or remove 'segm' from metric list)","If only exporting predictions, set format_only=True and remove unsupported metric names from metric=[...]","Check dataset_meta and GT annotation types: mask metrics require 'masks' or 'segmentations' in GT annotations; add them or drop the metric"],"exampleFix":"# before\nval_evaluator = dict(type='OVCocoMetric', metric=['bbox', 'segm'])\n# after (bbox-only model)\nval_evaluator = dict(type='OVCocoMetric', metric=['bbox'])","handlingStrategy":"validation","validationCode":"allowed = set(evaluator.metric) & {'bbox','segm','proposal'}\n# verify the dataset/model produce those prediction types before evaluation\nassert allowed == set(evaluator.metric), f'metrics without results: {set(evaluator.metric)-allowed}'","typeGuard":"def has_metric_result(result_files: dict, metric: str) -> bool:\n    return isinstance(result_files, dict) and metric in result_files","tryCatchPattern":"try:\n    metrics = evaluator.compute_metrics(result_files)\nexcept KeyError as e:\n    logging.warning('skipping unavailable metric: %s', e); metrics = {}","preventionTips":["Only list metrics whose prediction type your model head emits","For bbox-only models, drop 'segm' from metric list","Set format_only=True when exporting predictions instead of evaluating"],"tags":["mmdet","evaluation","coco-metric","open-vocabulary","config"],"backgroundTag":null,"analyzedSha":"cfd5d3a985b0249de009b67d04f37263e11cdf3d","analyzedAt":"2026-08-27T20:54:20.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}