tensorflow/models · error · ValueError

`saved_model_dir`, `model` or `concrete_function` must be sp

Error message

`saved_model_dir`, `model` or `concrete_function` must be specified.

What it means

Error "`saved_model_dir`, `model` or `concrete_function` must be specified." thrown in tensorflow/models.

Source

Thrown at official/vision/serving/export_tflite_lib.py:133

  Returns:
    A converted TFLite model with optional PTQ.

  Raises:
    ValueError: If `representative_dataset_path` is not present if integer
      quantization is requested, or `saved_model_dir`, `concrete_function` or
      `model` are not provided.
  """
  if saved_model_dir:
    converter = tf.lite.TFLiteConverter.from_saved_model(saved_model_dir)
  elif concrete_function is not None:
    converter = tf.lite.TFLiteConverter.from_concrete_functions(
        [concrete_function]
    )
  elif model is not None:
    converter = tf.lite.TFLiteConverter.from_keras_model(model)
  else:
    raise ValueError(
        '`saved_model_dir`, `model` or `concrete_function` must be specified.'
    )

  if quant_type:
    if quant_type.startswith('int8'):
      converter.optimizations = [tf.lite.Optimize.DEFAULT]
      converter.representative_dataset = functools.partial(
          representative_dataset,
          params=params,
          task=task,
          calibration_steps=calibration_steps)
      if quant_type.startswith('int8_full'):
        converter.target_spec.supported_ops = [
            tf.lite.OpsSet.TFLITE_BUILTINS_INT8
        ]
      if quant_type == 'int8_full':
        converter.inference_input_type = tf.uint8
        converter.inference_output_type = tf.uint8

View on GitHub (pinned to e006f5f0d5)

Solutions

  1. Provide one of saved_model_dir, model, or concrete_function to the TFLite converter.
  2. Pass the trained Keras model directly if no SavedModel directory exists.

When it happens

Trigger: Thrown at official/vision/serving/export_tflite_lib.py:133 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/c361678d3f898fa3. Report an issue: GitHub.