{"record":{"id":"52e945258add302e","repo":"tensorflow/models","slug":"class-agnostic-bbox-pred-needs-to-be-true-if-mul","errorCode":null,"errorMessage":"`class_agnostic_bbox_pred` needs to be True if multiple detection heads are specified.","messagePattern":"`class_agnostic_bbox_pred` needs to be True if multiple detection heads are specified\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/vision/modeling/maskrcnn_model.py","lineNumber":120,"sourceCode":"        'max_level': max_level,\n        'num_scales': num_scales,\n        'aspect_ratios': aspect_ratios,\n        'anchor_size': anchor_size,\n    }\n    self.backbone = backbone\n    self.decoder = decoder\n    self.rpn_head = rpn_head\n    if not isinstance(detection_head, (list, tuple)):\n      self.detection_head = [detection_head]\n    else:\n      self.detection_head = detection_head\n    self.roi_generator = roi_generator\n    if not isinstance(roi_sampler, (list, tuple)):\n      self.roi_sampler = [roi_sampler]\n    else:\n      self.roi_sampler = roi_sampler\n    if len(self.roi_sampler) > 1 and not class_agnostic_bbox_pred:\n      raise ValueError(\n          '`class_agnostic_bbox_pred` needs to be True if multiple detection heads are specified.'\n      )\n    self.roi_aligner = roi_aligner\n    self.detection_generator = detection_generator\n    self._include_mask = mask_head is not None\n    if outer_boxes_scale < 1.0:\n      raise ValueError('`outer_boxes_scale` should be a value >= 1.0.')\n    self.outer_boxes_scale = outer_boxes_scale\n    self.mask_head = mask_head\n    if self._include_mask and mask_sampler is None:\n      raise ValueError('`mask_sampler` is not provided in Mask R-CNN.')\n    self.mask_sampler = mask_sampler\n    if self._include_mask and mask_roi_aligner is None:\n      raise ValueError('`mask_roi_aligner` is not provided in Mask R-CNN.')\n    self.mask_roi_aligner = mask_roi_aligner\n    # Weights for the regression losses for each FRCNN layer.\n    # TODO(jiageng): Make the weights configurable.\n    self._cascade_layer_to_weights = [","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/vision/modeling/maskrcnn_model.py#L102-L138","documentation":"Error \"`class_agnostic_bbox_pred` needs to be True if multiple detection heads are specified.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/vision/modeling/maskrcnn_model.py:120 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e006f5f0d534913e49c1f1dae87364039fa607e2","analyzedAt":"2026-08-24T14:09:15.576Z","schemaVersion":2},"datasetVersion":"2026-08-24T17:17:21.512Z"}