open-mmlab/mmdetection · error · NotImplementedError
RandomCenterCropPad only support two testing pad mode:logica
Error message
RandomCenterCropPad only support two testing pad mode:logical-or and size_divisor.
What it means
RandomCenterCropPad's test-time padding accepts only two modes: 'logical' (target = w | pad_value, e.g. 32/64/127) or 'size_divisor'. Any other first element of test_pad_mode raises NotImplementedError in _test_aug.
Source
Thrown at mmdet/datasets/transforms/transforms.py:2126
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']:
# self.test_pad_add_pix is only used for centernet
target_h = (h | self.test_pad_mode[1]) + self.test_pad_add_pix
target_w = (w | self.test_pad_mode[1]) + self.test_pad_add_pix
elif self.test_pad_mode[0] in ['size_divisor']:
divisor = self.test_pad_mode[1]
target_h = int(np.ceil(h / divisor)) * divisor
target_w = int(np.ceil(w / divisor)) * divisor
else:
raise NotImplementedError(
'RandomCenterCropPad only support two testing pad mode:'
'logical-or and size_divisor.')
cropped_img, border, _ = self._crop_image_and_paste(
img, [h // 2, w // 2], [target_h, target_w])
results['img'] = cropped_img
results['img_shape'] = cropped_img.shape[:2]
results['border'] = border
return results
@autocast_box_type()
def transform(self, results: dict) -> dict:
img = results['img']
assert img.dtype == np.float32, (
'RandomCenterCropPad needs the input image of dtype np.float32,'
' please set "to_float32=True" in "LoadImageFromFile" pipeline')
h, w, c = img.shape
assert c == len(self.mean)View on GitHub (pinned to cfd5d3a985)
Solutions
- Use test_pad_mode=['logical', 32] (value must be a bitmask like 32/64/127)
- Or use test_pad_mode=['size_divisor', 32]
- Check exact spelling from the official YOLOX config
Example fix
# before test_pad_mode=dict(type='logical', size=32) # wrong structure # after test_pad_mode=['size_divisor', 32]
Defensive patterns
Strategy: validation
Validate before calling
assert self_cfg['test_pad_mode'][0] in ('logical', 'size_divisor'), 'unsupported pad mode' Type guard
def valid_pad_mode(m):
return isinstance(m, (list, tuple)) and len(m) == 2 and m[0] in ('logical', 'size_divisor') Prevention
- Copy pad mode verbatim from official YOLOX configs
- Validate test_pad_mode shape at config load time
When it happens
Trigger: Configuring dict(type='RandomCenterCropPad', test_pad_mode=['square', 32]) or a typo like 'logical_or' instead of 'logical', or passing a single value instead of a [mode, value] list.
Common situations: Customizing YOLOX test pipelines with a wrong pad mode name or malformed test_pad_mode tuple.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- type must be a str or valid type, but got {type(obj_type)}
- RandomCenterCropPad only supports bbox.
- Not supported YouTubeVIS datasetversion: {dataset_version}
- NUM_BRANCHES({num_branches}) != NUM_BLOCKS({len(num_blocks)}
- NUM_BRANCHES({num_branches}) != NUM_CHANNELS({len(num_channe
AI-assisted analysis of open-mmlab/mmdetection@cfd5d3a985 (2026-08-27).
Data as JSON: /api/errors/f2843b185c0c78ca.
Report an issue: GitHub.