{"record":{"id":"c9f5b65a145b3c75","repo":"tensorflow/models","slug":"number-of-channels-must-be-equal-to-the-length-of","errorCode":null,"errorMessage":"Number of channels must be equal to the length of per-channel pad value.","messagePattern":"Number of channels must be equal to the length of per-channel pad value\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/projects/centernet/ops/preprocess_ops.py","lineNumber":302,"sourceCode":"\n  with tf.name_scope('ResizeToRange'):\n    if image.get_shape().is_fully_defined():\n      if image.get_shape()[0] < image.get_shape()[1]:\n        new_image = _resize_landscape_image(image)\n      else:\n        new_image = _resize_portrait_image(image)\n      new_size = tf.constant(new_image.get_shape().as_list())\n    else:\n      new_image = tf.cond(\n          tf.less(tf.shape(image)[0], tf.shape(image)[1]),\n          lambda: _resize_landscape_image(image),\n          lambda: _resize_portrait_image(image))\n      new_size = tf.shape(new_image)\n\n    if pad_to_max_dimension:\n      channels = tf.unstack(new_image, axis=2)\n      if len(channels) != len(per_channel_pad_value):\n        raise ValueError('Number of channels must be equal to the length of '\n                         'per-channel pad value.')\n      new_image = tf.stack(\n          [\n              tf.pad(  # pylint: disable=g-complex-comprehension\n                  channels[i], [[0, max_dimension - new_size[0]],\n                                [0, max_dimension - new_size[1]]],\n                  constant_values=per_channel_pad_value[i])\n              for i in range(len(channels))\n          ],\n          axis=2)\n      new_image.set_shape([max_dimension, max_dimension, len(channels)])\n\n    result = [new_image, new_size]\n    if masks is not None:\n      new_masks = tf.expand_dims(masks, 3)\n      new_masks = tf.image.resize(\n          new_masks,\n          new_size[:-1],","sourceCodeStart":284,"sourceCodeEnd":320,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/projects/centernet/ops/preprocess_ops.py#L284-L320","documentation":"Error \"Number of channels must be equal to the length of per-channel pad value.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/projects/centernet/ops/preprocess_ops.py:302 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"}