{"record":{"id":"7554f65eb8377e04","repo":"open-mmlab/mmdetection","slug":"invalid-text-mode-self-text-mode","errorCode":null,"errorMessage":"Invalid text mode \"{self.text_mode}\".","messagePattern":"Invalid text mode \"(.+?)\"\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mmdet/datasets/refcoco.py","lineNumber":145,"sourceCode":"            instances = []\n            sentences = []\n            for grounding_anno in grounding_dict[img_id]:\n                texts = [x['raw'].lower() for x in grounding_anno['sentences']]\n                # random select one text\n                if self.text_mode == 'random':\n                    idx = random.randint(0, len(texts) - 1)\n                    text = [texts[idx]]\n                # concat all texts\n                elif self.text_mode == 'concat':\n                    text = [''.join(texts)]\n                # select the first text\n                elif self.text_mode == 'select_first':\n                    text = [texts[0]]\n                # use all texts\n                elif self.text_mode == 'original':\n                    text = texts\n                else:\n                    raise ValueError(f'Invalid text mode \"{self.text_mode}\".')\n                ins = [{\n                    'mask': grounding_anno['segmentation'],\n                    'ignore_flag': 0\n                }] * len(text)\n                instances.extend(ins)\n                sentences.extend(text)\n            data_info = {\n                'img_path': join_path(img_prefix, image['file_name']),\n                'img_id': img_id,\n                'instances': instances,\n                'text': sentences\n            }\n            data_list.append(data_info)\n\n        if len(data_list) == 0:\n            raise ValueError(f'No sample in split \"{self.split}\".')\n\n        return data_list","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/open-mmlab/mmdetection/blob/cfd5d3a985b0249de009b67d04f37263e11cdf3d/mmdet/datasets/refcoco.py#L127-L163","documentation":"RefCoco dataset in mmdet supports only specific text_mode values for turning the multi-sentence referring expressions of a region into training text. After handling 'select_first' and 'original', any other string falls through to this ValueError listing the offending mode.","triggerScenarios":"Constructing RefCoco (or building its transform pipeline in a config) with text_mode set to anything other than 'select_first' or 'original' — e.g. 'random', 'last', a typo like 'orginal', or None.","commonSituations":"Porting configs from older mmdet versions or other referring-expression codebases where text_mode='random' existed; typos in config strings; assuming all modes listed in a paper are implemented.","solutions":["Set text_mode='select_first' to use only the first referring expression per instance","Set text_mode='original' to keep all referring expressions","Check the installed mmdet version's refcoco.py for the exact list of supported modes and use one of those"],"exampleFix":"# before\ndataset = dict(type='RefCoco', ann_file=..., data_prefix=..., text_mode='random')\n# after\ndataset = dict(type='RefCoco', ann_file=..., data_prefix=..., text_mode='select_first')","handlingStrategy":"validation","validationCode":"from mmdet.datasets import RefCoco\nVALID_TEXT_MODES = {'select_first', 'original'}\ntext_mode = 'select_first' if text_mode not in VALID_TEXT_MODES else text_mode\ndataset = RefCoco(ann_file=..., data_prefix=..., split='train', text_mode=text_mode)","typeGuard":"def is_valid_text_mode(mode: str) -> bool:\n    return mode in {'select_first', 'original'}","tryCatchPattern":null,"preventionTips":["Pin the exact supported text_mode strings for your installed mmdet version by checking mmdet/datasets/refcoco.py","Treat config strings as an enum, not free text; validate against the known set at config parse time"],"tags":["mmdet","refcoco","text-mode","config","referring-expression"],"backgroundTag":"invalid-argument-value","analyzedSha":"cfd5d3a985b0249de009b67d04f37263e11cdf3d","analyzedAt":"2026-08-27T20:54:20.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}