open-mmlab/mmdetection · error · NotImplementedError

RandomCenterCropPad only supports bbox.

Error message

RandomCenterCropPad only supports bbox.

What it means

RandomCenterCropPad (used by YOLOX-style training) only operates on bounding boxes; if results contain 'gt_masks' or 'gt_seg_map' it raises NotImplementedError in the train branch.

Source

Thrown at mmdet/datasets/transforms/transforms.py:2099

                    gt_bboxes.clip_([new_h, new_w])
                keep = gt_bboxes.is_inside([new_h, new_w]).numpy()
                gt_bboxes = gt_bboxes[keep]

                results['gt_bboxes'] = gt_bboxes

                # ignore_flags
                if results.get('gt_ignore_flags', None) is not None:
                    gt_ignore_flags = results['gt_ignore_flags'][mask]
                    results['gt_ignore_flags'] = \
                        gt_ignore_flags[keep]

                # labels
                if results.get('gt_bboxes_labels', None) is not None:
                    gt_labels = results['gt_bboxes_labels'][mask]
                    results['gt_bboxes_labels'] = gt_labels[keep]

                if 'gt_masks' in results or 'gt_seg_map' in results:
                    raise NotImplementedError(
                        'RandomCenterCropPad only supports bbox.')

                return results

    def _test_aug(self, results):
        """Around padding the original image without cropping.

        The padding mode and value are from ``test_pad_mode``.

        Args:
            results (dict): Image infomations in the augment pipeline.

        Returns:
            results (dict): The updated dict.
        """
        img = results['img']
        h, w, c = img.shape
        if self.test_pad_mode[0] in ['logical_or']:

View on GitHub (pinned to cfd5d3a985)

Solutions

  1. Remove mask/seg loading (with_mask=False, with_seg=False) from LoadAnnotations
  2. Replace RandomCenterCropPad with e.g. RandomAffine or default crop/resize when doing segmentation
  3. Only use RandomCenterCropPad for pure detection pipelines

Example fix

# before
train_pipeline=[dict(type='LoadAnnotations', with_bbox=True, with_mask=True), dict(type='RandomCenterCropPad', ...)]
# after
train_pipeline=[dict(type='LoadAnnotations', with_bbox=True), dict(type='RandomCenterCropPad', ...)]
Defensive patterns

Strategy: validation

Validate before calling

assert 'gt_masks' not in results and 'gt_seg_map' not in results, 'RandomCenterCropPad is bbox-only'

Prevention

When it happens

Trigger: A config combines RandomCenterCropPad with mask/segmentation annotations loaded (with_mask=True or with_seg=True in LoadAnnotations, or dataset providing them).

Common situations: Reusing YOLOX COCO detection configs for instance segmentation without removing RandomCenterCropPad.

Related errors


AI-assisted analysis of open-mmlab/mmdetection@cfd5d3a985 (2026-08-27). Data as JSON: /api/errors/792fae1311a0f380. Report an issue: GitHub.