{"record":{"id":"89b5a99a1ec3afc4","repo":"open-mmlab/mmdetection","slug":"metric-should-be-one-of-bbox-segm-proposal-89b5a9","errorCode":null,"errorMessage":"metric should be one of 'bbox', 'segm', 'proposal', 'proposal_fast', but got {metric}.","messagePattern":"metric should be one of 'bbox', 'segm', 'proposal', 'proposal_fast', but got (.+?)\\.","errorType":"validation","errorClass":"KeyError","httpStatus":null,"severity":"error","filePath":"mmdet/evaluation/metrics/lvis_metric.py","lineNumber":104,"sourceCode":"                 iou_thrs: Optional[Union[float, Sequence[float]]] = None,\n                 metric_items: Optional[Sequence[str]] = None,\n                 format_only: bool = False,\n                 outfile_prefix: Optional[str] = None,\n                 collect_device: str = 'cpu',\n                 prefix: Optional[str] = None,\n                 file_client_args: dict = None,\n                 backend_args: dict = None) -> None:\n        if lvis is None:\n            raise RuntimeError(\n                'Package lvis is not installed. Please run \"pip install '\n                'git+https://github.com/lvis-dataset/lvis-api.git\".')\n        super().__init__(collect_device=collect_device, prefix=prefix)\n        # coco evaluation metrics\n        self.metrics = metric if isinstance(metric, list) else [metric]\n        allowed_metrics = ['bbox', 'segm', 'proposal', 'proposal_fast']\n        for metric in self.metrics:\n            if metric not in allowed_metrics:\n                raise KeyError(\n                    \"metric should be one of 'bbox', 'segm', 'proposal', \"\n                    f\"'proposal_fast', but got {metric}.\")\n\n        # do class wise evaluation, default False\n        self.classwise = classwise\n\n        # proposal_nums used to compute recall or precision.\n        self.proposal_nums = list(proposal_nums)\n\n        # iou_thrs used to compute recall or precision.\n        if iou_thrs is None:\n            iou_thrs = np.linspace(\n                .5, 0.95, int(np.round((0.95 - .5) / .05)) + 1, endpoint=True)\n        self.iou_thrs = iou_thrs\n        self.metric_items = metric_items\n        self.format_only = format_only\n        if self.format_only:\n            assert outfile_prefix is not None, 'outfile_prefix must be not'","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/open-mmlab/mmdetection/blob/cfd5d3a985b0249de009b67d04f37263e11cdf3d/mmdet/evaluation/metrics/lvis_metric.py#L86-L122","documentation":"LVISMetric.__init__ validates the `metric` argument against ['bbox', 'segm', 'proposal', 'proposal_fast'] and raises KeyError for anything else. This mirrors CocoMetric's contract but without 'proposal_fast' extras beyond the listed set; a typo or unsupported metric name fails fast at construction.","triggerScenarios":"Passing val_evaluator=dict(type='LVISMetric', metric='bbox_segm') or metric=['box'] or any string/list element not in the allowed list when building the evaluator.","commonSituations":"Copy-pasting a CocoMetric config with a metric key not valid for LVIS (e.g. 'proposal_fast' variants or 'segm' on a detection-only model); typos like 'boxes' or 'BBox'; assuming comma-separated 'bbox,segm' string works instead of a list.","solutions":["Set metric to a valid value or list of valid values, e.g. metric=['bbox', 'segm']","Use a Python list for multiple metrics instead of a comma-joined string","Check for typos and case: values must be lowercase and exactly match the allowed set"],"exampleFix":"// before\nval_evaluator=dict(type='LVISMetric', metric='bbox,segm')\n// after\nval_evaluator=dict(type='LVISMetric', metric=['bbox', 'segm'])","handlingStrategy":"type-guard","validationCode":"ALLOWED = {'bbox', 'segm', 'proposal', 'proposal_fast'}\nmetrics = metric if isinstance(metric, list) else [metric]\nbad = [m for m in metrics if m not in ALLOWED]\nassert not bad, f'Invalid LVIS metrics: {bad}; allowed: {sorted(ALLOWED)}'","typeGuard":"def is_valid_lvis_metric(metric) -> bool:\n    ALLOWED = {'bbox', 'segm', 'proposal', 'proposal_fast'}\n    vals = metric if isinstance(metric, (list, tuple)) else [metric]\n    return all(isinstance(m, str) and m in ALLOWED for m in vals)","tryCatchPattern":"try:\n    evaluator = LVISMetric(metric=metric)\nexcept KeyError as e:\n    raise ValueError(f'Invalid metric config {metric}: {e}') from e","preventionTips":["Use lists for multiple metrics, never comma-joined strings","Copy metric names from an up-to-date LVIS config in the repo","Lowercase only"],"tags":["mmdetection","lvis","config","argument-validation"],"backgroundTag":"value-not-in-allowed-set","analyzedSha":"cfd5d3a985b0249de009b67d04f37263e11cdf3d","analyzedAt":"2026-08-27T20:54:20.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}