{"record":{"id":"487903758e03f7c2","repo":"open-mmlab/mmdetection","slug":"albu-only-supports-bitmap-masks-now","errorCode":null,"errorMessage":"Albu only supports BitMap masks now","messagePattern":"Albu only supports BitMap masks now","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"mmdet/datasets/transforms/transforms.py","lineNumber":1725,"sourceCode":"\n    def _preprocess_results(self, results: dict) -> tuple:\n        \"\"\"Pre-processing results to facilitate the use of Albu.\"\"\"\n        if 'bboxes' in results:\n            # to list of boxes\n            if not isinstance(results['bboxes'], HorizontalBoxes):\n                raise NotImplementedError(\n                    'Albu only supports horizontal boxes now')\n            bboxes = results['bboxes'].numpy()\n            results['bboxes'] = [x for x in bboxes]\n            # add pseudo-field for filtration\n            if self.filter_lost_elements:\n                results['idx_mapper'] = np.arange(len(results['bboxes']))\n\n        # TODO: Support mask structure in albu\n        ori_masks = None\n        if 'masks' in results:\n            if isinstance(results['masks'], PolygonMasks):\n                raise NotImplementedError(\n                    'Albu only supports BitMap masks now')\n            ori_masks = results['masks']\n            if albumentations.__version__ < '0.5':\n                results['masks'] = results['masks'].masks\n            else:\n                results['masks'] = [mask for mask in results['masks'].masks]\n\n        return results, ori_masks\n\n    def _postprocess_results(\n            self,\n            results: dict,\n            ori_masks: Optional[Union[BitmapMasks,\n                                      PolygonMasks]] = None) -> dict:\n        \"\"\"Post-processing Albu output.\"\"\"\n        # albumentations may return np.array or list on different versions\n        if 'gt_bboxes_labels' in results and isinstance(\n                results['gt_bboxes_labels'], list):","sourceCodeStart":1707,"sourceCodeEnd":1743,"githubUrl":"https://github.com/open-mmlab/mmdetection/blob/cfd5d3a985b0249de009b67d04f37263e11cdf3d/mmdet/datasets/transforms/transforms.py#L1707-L1743","documentation":"Albu can only pass bitmap (instance) masks to albumentations; PolygonMasks (polygon annotations) are not supported and raise NotImplementedError during _preprocess_results.","triggerScenarios":"Using Albu in a pipeline where results['masks'] is a PolygonMasks object (e.g. instance-seg configs loading polygon annotations, typically COCO via LoadAnnotations with poly2mask=False).","commonSituations":"Adding Albu augmentations to instance segmentation training configs that use polygon masks.","solutions":["Set poly2mask=True in LoadAnnotations so masks become bitmap BitMasks","Or remove Albu and use native mmdet transforms for mask pipelines","Keep Albu only for detection (bbox-only) pipelines"],"exampleFix":"# before\npipeline=[dict(type='LoadAnnotations', with_mask=True, poly2mask=False), dict(type='Albu', ...)]\n# after\npipeline=[dict(type='LoadAnnotations', with_mask=True, poly2mask=True), dict(type='Albu', ...)]","handlingStrategy":"validation","validationCode":"from mmdet.structures.mask import PolygonMasks\nif 'masks' in results:\n    assert not isinstance(results['masks'], PolygonMasks), 'Albu needs bitmap masks'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set poly2mask=True when using Albu on segmentation data","Prefer native mmdet transforms for mask-heavy pipelines"],"tags":["mmdet","albumentations","instance-segmentation","polygon-masks"],"backgroundTag":"unsupported-data-format","analyzedSha":"cfd5d3a985b0249de009b67d04f37263e11cdf3d","analyzedAt":"2026-08-27T20:54:20.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}