open-mmlab/mmdetection · warning
DeprecationWarning: neg_bboxes is deprecated, please use "ne
Error message
DeprecationWarning: neg_bboxes is deprecated, please use "neg_priors" instead
What it means
Deprecation warning from SamplingResult.neg_bboxes: renamed to neg_priors (negative prior anchors). The property forwards to self.neg_priors and will be removed in a future release.
Source
Thrown at mmdet/models/task_modules/samplers/sampling_result.py:138
"""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.
Example:
>>> self = SamplingResult.random()
>>> print(f'self = {self.to(None)}')
>>> # xdoctest: +REQUIRES(--gpu)
>>> print(f'self = {self.to(0)}')
"""
_dict = self.__dict__
for key, value in _dict.items():
if isinstance(value, (torch.Tensor, BaseBoxes)):
_dict[key] = value.to(device)
return self
View on GitHub (pinned to cfd5d3a985)
Solutions
- Use sampling_result.neg_priors
- Migrate bboxes and pos_bboxes accesses at the same time
- Run tests to catch remaining legacy attribute accesses
Example fix
# before neg_rois = sampling_result.neg_bboxes # after neg_rois = sampling_result.neg_priors
Defensive patterns
Strategy: type-guard
Validate before calling
assert hasattr(result, 'neg_priors')
Type guard
def get_neg_priors(result):
return result.neg_priors if hasattr(result, 'neg_priors') else result.neg_bboxes Prevention
- Use neg_priors in hard-negative mining code
- Migrate all three renamed attributes at once
When it happens
Trigger: Accessing sampling_result.neg_bboxes in custom negative-sample handling, OHEM-style logic, or tests.
Common situations: Custom samplers / hard-negative mining code using the old attribute name after the priors rename.
Related errors
- DeprecationWarning: bboxes is deprecated, please use "priors
- DeprecationWarning: pos_bboxes is deprecated, please use "po
- ``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/346cff9e166c1452.
Report an issue: GitHub.