{"record":{"id":"a92a91095861b93c","repo":"open-mmlab/mmdetection","slug":"albu-only-supports-horizontal-boxes-now","errorCode":null,"errorMessage":"Albu only supports horizontal boxes now","messagePattern":"Albu only supports horizontal boxes now","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"mmdet/datasets/transforms/transforms.py","lineNumber":1713,"sourceCode":"        # TODO: gt_seg_map is not currently supported\n        # dict to albumentations format\n        results = self.mapper(results, self.keymap_to_albu)\n        results, ori_masks = self._preprocess_results(results)\n        results = self.aug(**results)\n        results = self._postprocess_results(results, ori_masks)\n        if results is None:\n            return None\n        # back to the original format\n        results = self.mapper(results, self.keymap_back)\n        results['img_shape'] = results['img'].shape[:2]\n        return results\n\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]","sourceCodeStart":1695,"sourceCodeEnd":1731,"githubUrl":"https://github.com/open-mmlab/mmdetection/blob/cfd5d3a985b0249de009b67d04f37263e11cdf3d/mmdet/datasets/transforms/transforms.py#L1695-L1731","documentation":"Albu's preprocessing requires results['bboxes'] to be an mmdet HorizontalBoxes instance (new data structure in mmdet 3.x). Legacy list/ndarray box formats raise NotImplementedError.","triggerScenarios":"Calling Albu.transform on a results dict whose 'bboxes' is a plain list or np.ndarray instead of HorizontalBoxes — e.g. calling the transform manually or in a custom pipeline that skipped LoadAnnotations/pack structure conversion.","commonSituations":"Migrating 2.x pipelines, custom pipelines inserting Albu before boxes are converted to HorizontalBoxes, or unit tests calling transforms directly with raw dicts.","solutions":["Ensure Albu comes after LoadAnnotations and the standard box conversion so 'bboxes' is a HorizontalBoxes","Wrap boxes manually: HorizontalBoxes(np.array(bboxes, dtype=np.float32))","Use mmdet 3.x-native pipeline order from official configs"],"exampleFix":"# before\nresults['bboxes'] = np.array([[0,0,10,10]], dtype=np.float32)\nalbu.transform(results)  # raises\n# after\nfrom mmdet.structures.bbox import HorizontalBoxes\nresults['bboxes'] = HorizontalBoxes(np.array([[0,0,10,10]], dtype=np.float32))","handlingStrategy":"type-guard","validationCode":"from mmdet.structures.bbox import HorizontalBoxes\nassert isinstance(results.get('bboxes'), HorizontalBoxes), 'need HorizontalBoxes'","typeGuard":"from mmdet.structures.bbox import HorizontalBoxes\ndef has_horizontal_boxes(results):\n    return isinstance(results.get('bboxes'), HorizontalBoxes)","tryCatchPattern":null,"preventionTips":["Use standard LoadAnnotations order in pipelines","In tests, construct results dicts with HorizontalBoxes"],"tags":["mmdet","albumentations","bbox","data-structure"],"backgroundTag":"unsupported-data-format","analyzedSha":"cfd5d3a985b0249de009b67d04f37263e11cdf3d","analyzedAt":"2026-08-27T20:54:20.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}