{"record":{"id":"f5579ed3b8416839","repo":"open-mmlab/mmdetection","slug":"results-does-not-contain-masks","errorCode":null,"errorMessage":"results does not contain masks.","messagePattern":"results does not contain masks\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"mmdet/datasets/transforms/transforms.py","lineNumber":3086,"sourceCode":"\n    def get_gt_masks(self, results: dict) -> BitmapMasks:\n        \"\"\"Get gt_masks originally or generated based on bboxes.\n\n        If gt_masks is not contained in results,\n        it will be generated based on gt_bboxes.\n        Args:\n            results (dict): Result dict.\n        Returns:\n            BitmapMasks: gt_masks, originally or generated based on bboxes.\n        \"\"\"\n        if results.get('gt_masks', None) is not None:\n            if self.paste_by_box:\n                warnings.warn('gt_masks is already contained in results, '\n                              'so paste_by_box is disabled.')\n            return results['gt_masks']\n        else:\n            if not self.paste_by_box:\n                raise RuntimeError('results does not contain masks.')\n            return results['gt_bboxes'].create_masks(results['img'].shape[:2])\n\n    def _select_object(self, results: dict) -> dict:\n        \"\"\"Select some objects from the source results.\"\"\"\n        bboxes = results['gt_bboxes']\n        labels = results['gt_bboxes_labels']\n        masks = self.get_gt_masks(results)\n        ignore_flags = results['gt_ignore_flags']\n\n        selected_inds = self._get_selected_inds(bboxes.shape[0])\n\n        selected_bboxes = bboxes[selected_inds]\n        selected_labels = labels[selected_inds]\n        selected_masks = masks[selected_inds]\n        selected_ignore_flags = ignore_flags[selected_inds]\n\n        results['gt_bboxes'] = selected_bboxes\n        results['gt_bboxes_labels'] = selected_labels","sourceCodeStart":3068,"sourceCodeEnd":3104,"githubUrl":"https://github.com/open-mmlab/mmdetection/blob/cfd5d3a985b0249de009b67d04f37263e11cdf3d/mmdet/datasets/transforms/transforms.py#L3068-L3104","documentation":"CopyPaste transform needs source objects; when results lack 'gt_masks' it can only synthesize object masks from boxes if paste_by_box=True. With paste_by_box=False and no gt_masks it raises RuntimeError.","triggerScenarios":"Configuring dict(type='CopyPaste', paste_by_box=False) on a dataset/branch that provides only bboxes (no masks), so _get_source_mask has nothing to return.","commonSituations":"Using CopyPaste on detection-only data; or mis-set paste_by_box when the auxiliary dataset has no mask annotations.","solutions":["Set paste_by_box=True in the CopyPaste config so masks are created from gt_bboxes","Provide gt_masks in the source results (enable with_mask=True in the aux pipeline)","Do not use CopyPaste on bbox-only datasets"],"exampleFix":"# before\ndict(type='CopyPaste', paste_by_box=False)\n# after\ndict(type='CopyPaste', paste_by_box=True)","handlingStrategy":"validation","validationCode":"assert results.get('gt_masks') is not None or self.paste_by_box, 'need gt_masks or paste_by_box=True'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set paste_by_box=True for bbox-only sources","Ensure aux dataset pipelines provide masks when needed"],"tags":["mmdet","copypaste","masks","config"],"backgroundTag":"invalid-config-value","analyzedSha":"cfd5d3a985b0249de009b67d04f37263e11cdf3d","analyzedAt":"2026-08-27T20:54:20.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}