{"record":{"id":"fedca8934478c618","repo":"tensorflow/models","slug":"image-mean-and-image-std-should-be-the-same-ty","errorCode":null,"errorMessage":"`image_mean` and `image_std` should be the same type.","messagePattern":"`image_mean` and `image_std` should be the same type\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/vision/utils/object_detection/visualization_utils.py","lineNumber":437,"sourceCode":"  for i in range(1, num_classes + 1):\n    category_index[i] = {'id': i, 'name': str(i)}\n\n  def _denormalize_images(images: tf.Tensor) -> tf.Tensor:\n    if image_mean is None and image_std is None:\n      images *= tf.constant(\n          preprocess_ops.STDDEV_RGB, shape=[1, 1, 3], dtype=images.dtype\n      )\n      images += tf.constant(\n          preprocess_ops.MEAN_RGB, shape=[1, 1, 3], dtype=images.dtype\n      )\n    elif image_mean is not None and image_std is not None:\n      if isinstance(image_mean, float) and isinstance(image_std, float):\n        images = images * image_std + image_mean\n      elif isinstance(image_mean, list) and isinstance(image_std, list):\n        images *= tf.constant(image_std, shape=[1, 1, 3], dtype=images.dtype)\n        images += tf.constant(image_mean, shape=[1, 1, 3], dtype=images.dtype)\n      else:\n        raise ValueError(\n            '`image_mean` and `image_std` should be the same type.'\n        )\n    else:\n      raise ValueError(\n          'Both `image_mean` and `image_std` should be set or None at the same '\n          'time.'\n      )\n    return tf.cast(images, dtype=tf.uint8)\n\n  if images.shape[3] > 3:\n    images = images[:, :, :, 0:3]\n  elif images.shape[3] == 1:\n    images = tf.image.grayscale_to_rgb(images)\n\n  images = tf.nest.map_structure(\n      tf.identity,\n      tf.map_fn(\n          _denormalize_images,","sourceCodeStart":419,"sourceCodeEnd":455,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/vision/utils/object_detection/visualization_utils.py#L419-L455","documentation":"Error \"`image_mean` and `image_std` should be the same type.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/vision/utils/object_detection/visualization_utils.py:437 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Make image_mean and image_std the same type (both lists or both floats).","Convert one of them so their types match."],"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"}