{"record":{"id":"b0b88d0137e43fa2","repo":"tensorflow/models","slug":"mask-sampler-is-not-provided-in-mask-r-cnn","errorCode":null,"errorMessage":"`mask_sampler` is not provided in Mask R-CNN.","messagePattern":"`mask_sampler` is not provided in Mask R-CNN\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/vision/modeling/maskrcnn_model.py","lineNumber":131,"sourceCode":"      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 = [\n        [10.0, 10.0, 5.0, 5.0],\n        [20.0, 20.0, 10.0, 10.0],\n        [30.0, 30.0, 15.0, 15.0],\n    ]\n\n  def call(  # pytype: disable=signature-mismatch  # overriding-parameter-count-checks\n      self,\n      images: tf.Tensor,\n      image_shape: tf.Tensor,\n      anchor_boxes: Optional[Mapping[str, tf.Tensor]] = None,\n      gt_boxes: Optional[tf.Tensor] = None,","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/vision/modeling/maskrcnn_model.py#L113-L149","documentation":"Error \"`mask_sampler` is not provided in Mask R-CNN.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/vision/modeling/maskrcnn_model.py:131 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Provide a mask_sampler when constructing the Mask R-CNN model.","Build the model through the standard factory which wires up the mask sampler."],"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"}