{"record":{"id":"3f48ed80ff353222","repo":"tensorflow/models","slug":"for-raw-image-feature-height-width-and-num-chann","errorCode":null,"errorMessage":"For raw image feature, height, width and num_channels fields are required.","messagePattern":"For raw image feature, height, width and num_channels fields are required\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/vision/data/tf_example_builder.py","lineNumber":128,"sourceCode":"      >>> example_builder.add_encoded_image_feature(\n              image_bytes, feature_prefix='depth')\n\n    Args:\n      encoded_image: Encoded image string.\n      image_format: Image format string.\n      height: Number of rows.\n      width: Number of columns.\n      num_channels: Number of channels.\n      image_source_id: Unique string ID to identify the image.\n      feature_prefix: Feature prefix for image features.\n      label: the label or a list of labels for the image.\n\n    Returns:\n      The builder object for subsequent method calls.\n    \"\"\"\n    if image_format == 'RAW':\n      if not (height and width and num_channels):\n        raise ValueError('For raw image feature, height, width and '\n                         'num_channels fields are required.')\n    if not all((height, width, num_channels, image_format)):\n      (height, width, num_channels, image_format) = (\n          image_utils.decode_image_metadata(encoded_image))\n    else:\n      image_format = image_utils.validate_image_format(image_format)\n\n    feature_key = tf_example_feature_key.EncodedImageFeatureKey(feature_prefix)\n\n    # If source ID is not provided, we use hashed encoded image as the source\n    # ID. Note that we only keep 24 bits to be consistent with the Model Garden\n    # requirement, which will transform the source ID into float32.\n    if not image_source_id:\n      hashed_image = int(hashlib.blake2s(encoded_image).hexdigest(), 16)\n      image_source_id = _to_bytes(str(hashed_image % ((1 << 24) + 1)))\n\n    if label is not None:\n      self.add_ints_feature(feature_key.label, label)","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/vision/data/tf_example_builder.py#L110-L146","documentation":"Error \"For raw image feature, height, width and num_channels fields are required.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/vision/data/tf_example_builder.py:128 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"}