open-mmlab/mmdetection · warning
DeprecationWarning: bboxes is deprecated, please use "priors
Error message
DeprecationWarning: bboxes is deprecated, please use "priors" instead
What it means
Deprecation warning from SamplingResult.bboxes property: the bboxes/pos_bboxes/neg_bboxes attributes were renamed to priors/pos_priors/neg_priors because sampled 'boxes' are actually the prior anchors. The property just forwards to self.priors and will be removed.
Source
Thrown at mmdet/models/task_modules/samplers/sampling_result.py:126
box_dim = gt_bboxes.box_dim if isinstance(gt_bboxes, BaseBoxes) else 4
if gt_bboxes.numel() == 0:
# hack for index error case
assert self.pos_assigned_gt_inds.numel() == 0
self.pos_gt_bboxes = gt_bboxes.view(-1, box_dim)
else:
if len(gt_bboxes.shape) < 2:
gt_bboxes = gt_bboxes.view(-1, box_dim)
self.pos_gt_bboxes = gt_bboxes[self.pos_assigned_gt_inds.long()]
@property
def priors(self):
"""torch.Tensor: concatenated positive and negative priors"""
return cat_boxes([self.pos_priors, self.neg_priors])
@property
def bboxes(self):
"""torch.Tensor: concatenated positive and negative boxes"""
warnings.warn('DeprecationWarning: bboxes is deprecated, '
'please use "priors" instead')
return self.priors
@property
def pos_bboxes(self):
warnings.warn('DeprecationWarning: pos_bboxes is deprecated, '
'please use "pos_priors" instead')
return self.pos_priors
@property
def neg_bboxes(self):
warnings.warn('DeprecationWarning: neg_bboxes is deprecated, '
'please use "neg_priors" instead')
return self.neg_priors
def to(self, device):
"""Change the device of the data inplace.
View on GitHub (pinned to cfd5d3a985)
Solutions
- Use sampling_result.priors instead of .bboxes
- Similarly switch pos_bboxes→pos_priors, neg_bboxes→neg_priors (warnings 317/318)
- Grep codebase for '_bboxes' usages on SamplingResult objects
Example fix
# before rois = sampling_result.bboxes # after rois = sampling_result.priors
Defensive patterns
Strategy: type-guard
Validate before calling
assert hasattr(result, 'priors'), 'SamplingResult lacks priors; upgrade mmdet'
Type guard
def get_priors(result):
return result.priors if hasattr(result, 'priors') else result.bboxes Prevention
- Consume SamplingResult via priors/pos_priors/neg_priors
- Feature-detect attributes when supporting multiple mmdet versions
When it happens
Trigger: Accessing sampling_result.bboxes in custom sampler/roi-head code or tests; anything consuming SamplingResult output written against the old attribute names.
Common situations: Custom RoI heads or debugging code reading result.bboxes / result.pos_bboxes after mmdet renamed sampling fields to priors.
Related errors
- DeprecationWarning: pos_bboxes is deprecated, please use "po
- DeprecationWarning: neg_bboxes is deprecated, please use "ne
- ``grid_anchors`` would be deprecated soon. Please use ``grid
- ``single_level_grid_anchors`` would be deprecated soon. Plea
- pretrained must be a str or None
AI-assisted analysis of open-mmlab/mmdetection@cfd5d3a985 (2026-08-27).
Data as JSON: /api/errors/9c8e1610a5b669c7.
Report an issue: GitHub.