{"record":{"id":"097661428ecffa15","repo":"facebookresearch/detectron2","slug":"conversion-from-boxmode-to-is-not-supported","errorCode":null,"errorMessage":"Conversion from BoxMode {} to {} is not supported yet","messagePattern":"Conversion from BoxMode (.+?) to (.+?) is not supported yet","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"detectron2/structures/boxes.py","lineNumber":116,"sourceCode":"            arr[:, 3] = arr[:, 1] + new_h\n\n            arr = arr[:, :4].to(dtype=original_dtype)\n        elif from_mode == BoxMode.XYWH_ABS and to_mode == BoxMode.XYWHA_ABS:\n            original_dtype = arr.dtype\n            arr = arr.double()\n            arr[:, 0] += arr[:, 2] / 2.0\n            arr[:, 1] += arr[:, 3] / 2.0\n            angles = torch.zeros((arr.shape[0], 1), dtype=arr.dtype)\n            arr = torch.cat((arr, angles), axis=1).to(dtype=original_dtype)\n        else:\n            if to_mode == BoxMode.XYXY_ABS and from_mode == BoxMode.XYWH_ABS:\n                arr[:, 2] += arr[:, 0]\n                arr[:, 3] += arr[:, 1]\n            elif from_mode == BoxMode.XYXY_ABS and to_mode == BoxMode.XYWH_ABS:\n                arr[:, 2] -= arr[:, 0]\n                arr[:, 3] -= arr[:, 1]\n            else:\n                raise NotImplementedError(\n                    \"Conversion from BoxMode {} to {} is not supported yet\".format(\n                        from_mode, to_mode\n                    )\n                )\n\n        if single_box:\n            return original_type(arr.flatten().tolist())\n        if is_numpy:\n            return arr.numpy()\n        else:\n            return arr\n\n\nclass Boxes:\n    \"\"\"\n    This structure stores a list of boxes as a Nx4 torch.Tensor.\n    It supports some common methods about boxes\n    (`area`, `clip`, `nonempty`, etc),","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/facebookresearch/detectron2/blob/a2f4a8771ab77e8411c26b27f24f9489a28a2453/detectron2/structures/boxes.py#L98-L134","documentation":"BoxMode.convert implements only XYXY_ABS<->XYWH_ABS and to/from XYWHA_REL (partial) conversions. Any other pair, notably anything involving XYWHA_ABS or XYWHA_REL with absolute inputs in unsupported directions, raises NotImplementedError.","triggerScenarios":"Calling BoxMode.convert(boxes, from_mode=BoxMode.XYWHA_ABS, to_mode=BoxMode.XYXY_ABS); the rotated-box branch only handles a subset of direction/mode pairs.","commonSituations":"Rotated detection (RRPN/Rotated BBox datasets like DOTA) converting rotated annotations to axis-aligned boxes; mixing REL and ABS conventions across datasets.","solutions":["Convert manually (e.g. with shapely or box_ops) for the unsupported pair","Convert to an intermediate supported mode (XYXY_ABS or XYWH_ABS) in two steps if direction is the issue","Use detectron2.structures.rotated_boxes.rotated_box_to_aligned_box for XYWHA_ABS -> XYXY_ABS"],"exampleFix":"# before\nboxes_xyxy = BoxMode.convert(boxes, BoxMode.XYWHA_ABS, BoxMode.XYXY_ABS)\n# after\nfrom detectron2.structures.rotated_boxes import rotated_box_to_aligned_box\nboxes_xyxy = rotated_box_to_aligned_box(boxes)","handlingStrategy":"fallback","validationCode":"from detectron2.structures import BoxMode\nsupported = {(BoxMode.XYXY_ABS, BoxMode.XYWH_ABS), (BoxMode.XYWH_ABS, BoxMode.XYXY_ABS), (BoxMode.XYXY_ABS, BoxMode.XYWHA_REL), (BoxMode.XYWHA_REL, BoxMode.XYXY_ABS), (BoxMode.XYWH_ABS, BoxMode.XYWHA_REL)}\nassert (from_mode, to_mode) in supported, 'unsupported BoxMode conversion'","typeGuard":"def can_convert(f, t) -> bool:\n    return (f, t) in {(BoxMode.XYXY_ABS, BoxMode.XYWH_ABS), (BoxMode.XYWH_ABS, BoxMode.XYXY_ABS), (BoxMode.XYXY_ABS, BoxMode.XYWHA_REL), (BoxMode.XYWHA_REL, BoxMode.XYXY_ABS), (BoxMode.XYWH_ABS, BoxMode.XYWHA_REL)}","tryCatchPattern":"try:\n    out = BoxMode.convert(b, f, t)\nexcept NotImplementedError:\n    out = manual_convert(b, f, t)  # e.g. rotated_box_to_aligned_box","preventionTips":["Normalize all boxes to XYXY_ABS/XYWH_ABS at load time","Use rotated_boxes utilities for XYWHA conversions"],"tags":["detectron2","box-mode","geometry","not-implemented"],"backgroundTag":"unsupported-coordinate-conversion","analyzedSha":"a2f4a8771ab77e8411c26b27f24f9489a28a2453","analyzedAt":"2026-08-27T12:08:21.260Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}