{"record":{"id":"f75cd11b6fbc5350","repo":"tensorflow/models","slug":"expected-the-input-masks-height-width-has","errorCode":null,"errorMessage":"Expected the input masks (..., height, width) has rank >= 2, was: %s","messagePattern":"Expected the input masks \\(\\.\\.\\., height, width\\) has rank >= 2, was: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/projects/panoptic/modeling/layers/panoptic_segmentation_generator.py","lineNumber":40,"sourceCode":"from official.vision.ops import spatial_transform_ops\n\n\ndef _batch_count_ones(masks: tf.Tensor,\n                      dtype: tf.dtypes.DType = tf.int32) -> tf.Tensor:\n  \"\"\"Counts the ones/trues for each mask in the batch.\n\n  Args:\n    masks: A tensor in shape (..., height, width) with arbitrary numbers of\n      batch dimensions.\n    dtype: DType of the resulting tensor. Default is tf.int32.\n\n  Returns:\n    A tensor which contains the count of non-zero elements for each mask in the\n    batch. The rank of the resulting tensor is equal to rank(masks) - 2.\n  \"\"\"\n  masks_shape = masks.get_shape().as_list()\n  if len(masks_shape) < 2:\n    raise ValueError(\n        'Expected the input masks (..., height, width) has rank >= 2, was: %s' %\n        masks_shape)\n  return tf.reduce_sum(tf.cast(masks, dtype), axis=[-2, -1])\n\n\nclass PanopticSegmentationGenerator(tf_keras.layers.Layer):\n  \"\"\"Panoptic segmentation generator layer.\"\"\"\n\n  def __init__(\n      self,\n      output_size: List[int],\n      max_num_detections: int,\n      stuff_classes_offset: int,\n      mask_binarize_threshold: float = 0.5,\n      score_threshold: float = 0.5,\n      things_overlap_threshold: float = 0.5,\n      stuff_area_threshold: float = 4096,\n      things_class_label: int = 1,","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/projects/panoptic/modeling/layers/panoptic_segmentation_generator.py#L22-L58","documentation":"Error \"Expected the input masks (..., height, width) has rank >= 2, was: %s\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/projects/panoptic/modeling/layers/panoptic_segmentation_generator.py:40 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"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"}