tensorflow/models · error · ValueError
`class_agnostic_bbox_pred` needs to be True if multiple dete
Error message
`class_agnostic_bbox_pred` needs to be True if multiple detection heads are specified.
What it means
Error "`class_agnostic_bbox_pred` needs to be True if multiple detection heads are specified." thrown in tensorflow/models.
Source
Thrown at official/vision/modeling/maskrcnn_model.py:120
'max_level': max_level,
'num_scales': num_scales,
'aspect_ratios': aspect_ratios,
'anchor_size': anchor_size,
}
self.backbone = backbone
self.decoder = decoder
self.rpn_head = rpn_head
if not isinstance(detection_head, (list, tuple)):
self.detection_head = [detection_head]
else:
self.detection_head = detection_head
self.roi_generator = roi_generator
if not isinstance(roi_sampler, (list, tuple)):
self.roi_sampler = [roi_sampler]
else:
self.roi_sampler = roi_sampler
if len(self.roi_sampler) > 1 and not class_agnostic_bbox_pred:
raise ValueError(
'`class_agnostic_bbox_pred` needs to be True if multiple detection heads are specified.'
)
self.roi_aligner = roi_aligner
self.detection_generator = detection_generator
self._include_mask = mask_head is not None
if outer_boxes_scale < 1.0:
raise ValueError('`outer_boxes_scale` should be a value >= 1.0.')
self.outer_boxes_scale = outer_boxes_scale
self.mask_head = mask_head
if self._include_mask and mask_sampler is None:
raise ValueError('`mask_sampler` is not provided in Mask R-CNN.')
self.mask_sampler = mask_sampler
if self._include_mask and mask_roi_aligner is None:
raise ValueError('`mask_roi_aligner` is not provided in Mask R-CNN.')
self.mask_roi_aligner = mask_roi_aligner
# Weights for the regression losses for each FRCNN layer.
# TODO(jiageng): Make the weights configurable.
self._cascade_layer_to_weights = [View on GitHub (pinned to e006f5f0d5)
Solutions
- Set class_agnostic_bbox_pred to True when multiple detection heads are configured.
- Reduce to a single detection head if you need per-class box prediction.
When it happens
Trigger: Thrown at official/vision/modeling/maskrcnn_model.py:120 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of tensorflow/models@e006f5f0d5 (2026-08-24).
Data as JSON: /api/errors/52e945258add302e.
Report an issue: GitHub.