tensorflow/models · error · ValueError

add_tpu_function_alias is only allowed for input_type of: im

Error message

add_tpu_function_alias is only allowed for input_type of: image_tensor, image_bytes, tf_example.

What it means

Error "add_tpu_function_alias is only allowed for input_type of: image_tensor, image_bytes, tf_example." thrown in tensorflow/models.

Source

Thrown at official/vision/serving/export_saved_model_lib.py:157

          input_image_size=input_image_size,
          input_type=input_type,
          num_channels=num_channels,
          input_name=input_name,
      )
    else:
      raise ValueError(
          'Export module not implemented for {} task.'.format(type(params.task))
      )

  if add_tpu_function_alias:
    if input_type == 'image_tensor':
      inference_func = export_module.inference_from_image_tensors
    elif input_type == 'image_bytes':
      inference_func = export_module.inference_from_image_bytes
    elif input_type == 'tf_example':
      inference_func = export_module.inference_from_tf_example
    else:
      raise ValueError(
          'add_tpu_function_alias is only allowed for input_type of:'
          ' image_tensor, image_bytes, tf_example.'
      )
    save_options = tf.saved_model.SaveOptions(
        function_aliases={
            'tpu_candidate': inference_func,
        }
    )

  export_base.export(
      export_module,
      function_keys=function_keys if function_keys else [input_type],
      export_savedmodel_dir=output_saved_model_directory,
      checkpoint=checkpoint,
      checkpoint_path=checkpoint_path,
      timestamped=False,
      save_options=save_options,
  )

View on GitHub (pinned to e006f5f0d5)

Solutions

  1. Set input_type to 'image_tensor', 'image_bytes', or 'tf_example' when add_tpu_function_alias is enabled.
  2. Disable add_tpu_function_alias for other input types.

When it happens

Trigger: Thrown at official/vision/serving/export_saved_model_lib.py:157 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of tensorflow/models@e006f5f0d5 (2026-08-24). Data as JSON: /api/errors/baebfe780c902fef. Report an issue: GitHub.