open-mmlab/mmdetection · warning
DeprecationWarning: onnx_delta2bbox is deprecated in the cas
Error message
DeprecationWarning: onnx_delta2bbox is deprecated in the case of batch decoding and non-ONNX, please use “delta2bbox” instead. In order to improve the decoding speed, the batch function will no longer be supported.
What it means
Deprecation warning from DeltaXYWHBBoxCoder.decode: the else-branch uses the ONNX export helper onnx_delta2bbox even outside ONNX export when pred_bboxes is a 3-D (batched) tensor. Batched decoding via this path is deprecated for speed; use the vectorized delta2bbox instead, as batch support in onnx_delta2bbox will be dropped.
Source
Thrown at mmdet/models/task_modules/coders/delta_xywh_bbox_coder.py:112
width and height.
Returns:
Union[torch.Tensor, :obj:`BaseBoxes`]: Decoded boxes.
"""
bboxes = get_box_tensor(bboxes)
assert pred_bboxes.size(0) == bboxes.size(0)
if pred_bboxes.ndim == 3:
assert pred_bboxes.size(1) == bboxes.size(1)
if pred_bboxes.ndim == 2 and not torch.onnx.is_in_onnx_export():
# single image decode
decoded_bboxes = delta2bbox(bboxes, pred_bboxes, self.means,
self.stds, max_shape, wh_ratio_clip,
self.clip_border, self.add_ctr_clamp,
self.ctr_clamp)
else:
if pred_bboxes.ndim == 3 and not torch.onnx.is_in_onnx_export():
warnings.warn(
'DeprecationWarning: onnx_delta2bbox is deprecated '
'in the case of batch decoding and non-ONNX, '
'please use “delta2bbox” instead. In order to improve '
'the decoding speed, the batch function will no '
'longer be supported. ')
decoded_bboxes = onnx_delta2bbox(bboxes, pred_bboxes, self.means,
self.stds, max_shape,
wh_ratio_clip, self.clip_border,
self.add_ctr_clamp,
self.ctr_clamp)
if self.use_box_type:
assert decoded_bboxes.size(-1) == 4, \
('Cannot warp decoded boxes with box type when decoded boxes'
'have shape of (N, num_classes * 4)')
decoded_bboxes = HorizontalBoxes(decoded_bboxes)
return decoded_bboxes
View on GitHub (pinned to cfd5d3a985)
Solutions
- Decode per-sample (loop over batch) or reshape so pred_bboxes is 2-D before decode
- Ensure code uses delta2bbox path (the branch above) rather than falling into the ONNX helper
- Update mmdet — newer implementations handle batched decoding natively
Example fix
# before decoded = coder.decode(anchors, batched_pred_bboxes) # ndim==3 # after decoded = torch.cat([coder.decode(anchors[i:i+1].squeeze(0), batched_pred_bboxes[i]) for i in range(batched_pred_bboxes.shape[0])])
Defensive patterns
Strategy: validation
Validate before calling
assert pred_bboxes.ndim == 2 or torch.onnx.is_in_onnx_export(), 'decode batched deltas per-sample or use delta2bbox path'
Prevention
- Keep decode inputs 2-D outside ONNX export
- Batch: loop or vectorize with delta2bbox rather than the ONNX helper
When it happens
Trigger: Calling coder.decode(...) with pred_bboxes.ndim == 3 (batched deltas) while not inside torch.onnx.export; e.g. test-time batch prediction or aug-test code feeding batched proposals through a DeltaXYWHBBoxCoder on the non-ONNX path.
Common situations: Batch inference / multi-image test loaders hitting a decode path designed for ONNX tracing; upgrading mmdet versions where batch decoding via onnx_delta2bbox is being removed.
Related errors
- pretrained must be a str or None
- DeprecationWarning: pretrained is deprecated, please use "in
- DeprecationWarning: `num_anchors` is deprecated, for consist
- DeprecationWarning: anchor_generator is deprecated, please u
- You are calling `simple_test_bboxes` in `dense_test_mixins`,
AI-assisted analysis of open-mmlab/mmdetection@cfd5d3a985 (2026-08-27).
Data as JSON: /api/errors/89d9cb4ed75df181.
Report an issue: GitHub.