{"record":{"id":"2b4b9bf20bfd2867","repo":"open-mmlab/mmdetection","slug":"randomaffine-only-supports-bbox","errorCode":null,"errorMessage":"RandomAffine only supports bbox.","messagePattern":"RandomAffine only supports bbox\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"mmdet/datasets/transforms/transforms.py","lineNumber":2859,"sourceCode":"        results['img'] = img\n        results['img_shape'] = img.shape[:2]\n\n        bboxes = results['gt_bboxes']\n        num_bboxes = len(bboxes)\n        if num_bboxes:\n            bboxes.project_(warp_matrix)\n            if self.bbox_clip_border:\n                bboxes.clip_([height, width])\n            # remove outside bbox\n            valid_index = bboxes.is_inside([height, width]).numpy()\n            results['gt_bboxes'] = bboxes[valid_index]\n            results['gt_bboxes_labels'] = results['gt_bboxes_labels'][\n                valid_index]\n            results['gt_ignore_flags'] = results['gt_ignore_flags'][\n                valid_index]\n\n            if 'gt_masks' in results:\n                raise NotImplementedError('RandomAffine only supports bbox.')\n        return results\n\n    def __repr__(self):\n        repr_str = self.__class__.__name__\n        repr_str += f'(max_rotate_degree={self.max_rotate_degree}, '\n        repr_str += f'max_translate_ratio={self.max_translate_ratio}, '\n        repr_str += f'scaling_ratio_range={self.scaling_ratio_range}, '\n        repr_str += f'max_shear_degree={self.max_shear_degree}, '\n        repr_str += f'border={self.border}, '\n        repr_str += f'border_val={self.border_val}, '\n        repr_str += f'bbox_clip_border={self.bbox_clip_border})'\n        return repr_str\n\n    @staticmethod\n    def _get_rotation_matrix(rotate_degrees: float) -> np.ndarray:\n        radian = math.radians(rotate_degrees)\n        rotation_matrix = np.array(\n            [[np.cos(radian), -np.sin(radian), 0.],","sourceCodeStart":2841,"sourceCodeEnd":2877,"githubUrl":"https://github.com/open-mmlab/mmdetection/blob/cfd5d3a985b0249de009b67d04f37263e11cdf3d/mmdet/datasets/transforms/transforms.py#L2841-L2877","documentation":"RandomAffine (YOLO-style) supports only bounding-box annotations; after filtering boxes it raises NotImplementedError if 'gt_masks' is present in results.","triggerScenarios":"A training pipeline includes RandomAffine while results carry gt_masks (mask annotations loaded) — typically instance-seg datasets or with_mask=True.","commonSituations":"Adapting YOLOv5/YOLOX detection configs (which use RandomAffine) to instance segmentation datasets.","solutions":["Remove with_mask/with_seg from LoadAnnotations","For segmentation, swap RandomAffine for transforms supporting masks (e.g. RandomResize + RandomFlip + Crop)","Keep RandomAffine only in detection-only pipelines"],"exampleFix":"# before\ndict(type='LoadAnnotations', with_bbox=True, with_mask=True), dict(type='RandomAffine', scale=(0.5,1.15))\n# after\ndict(type='LoadAnnotations', with_bbox=True), dict(type='RandomAffine', scale=(0.5,1.15))","handlingStrategy":"validation","validationCode":"assert 'gt_masks' not in results, 'RandomAffine is bbox-only'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not combine RandomAffine with mask loading","Use mask-aware transforms for segmentation training"],"tags":["mmdet","randomaffine","yolo","segmentation"],"backgroundTag":"unsupported-pipeline-combination","analyzedSha":"cfd5d3a985b0249de009b67d04f37263e11cdf3d","analyzedAt":"2026-08-27T20:54:20.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}