tensorflow config_error ai_generated true

InvalidArgumentError: The SavedModel's tag set is empty or does not match the requested tags

ID: tensorflow/savedmodel-tagset-mismatch

Also available as: JSON · Markdown · 中文
92%Fix Rate
88%Confidence
1Evidence
2023-01-20First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
tensorflow 2.8 active
tensorflow 2.9 active
tensorflow 2.10 active

Root Cause

When loading a SavedModel with tf.saved_model.load(), the 'tags' argument does not match any MetaGraphDef present in the SavedModel, or the SavedModel was saved without tags.

generic

中文

使用 tf.saved_model.load() 加载 SavedModel 时,‘tags’ 参数与 SavedModel 中存在的任何 MetaGraphDef 不匹配,或者 SavedModel 保存时未指定标签。

Official Documentation

https://www.tensorflow.org/guide/saved_model#specifying_tags_when_loading

Workarounds

  1. 95% success Use saved_model_cli show --dir /path/to/saved_model --all to list available tag sets, then pass the correct tags to tf.saved_model.load(). For example: model = tf.saved_model.load('/path/to/saved_model', tags=['serve'])
    Use saved_model_cli show --dir /path/to/saved_model --all to list available tag sets, then pass the correct tags to tf.saved_model.load(). For example: model = tf.saved_model.load('/path/to/saved_model', tags=['serve'])
  2. 90% success If no tags were saved, reload using tf.saved_model.load(path, tags=[]) or save the model again with explicit tags using tf.saved_model.save(model, path, signatures=..., tags=['serve']).
    If no tags were saved, reload using tf.saved_model.load(path, tags=[]) or save the model again with explicit tags using tf.saved_model.save(model, path, signatures=..., tags=['serve']).

中文步骤

  1. 使用 saved_model_cli show --dir /path/to/saved_model --all 列出可用的标签集,然后将正确的标签传递给 tf.saved_model.load()。例如:model = tf.saved_model.load('/path/to/saved_model', tags=['serve'])
  2. 如果未保存任何标签,请使用 tf.saved_model.load(path, tags=[]) 重新加载,或者使用显式标签重新保存模型:tf.saved_model.save(model, path, signatures=..., tags=['serve'])。

Dead Ends

Common approaches that don't work:

  1. 80% fail

    The error is tag-specific, not path-related; another SavedModel may have the same tag mismatch.

  2. 95% fail

    Debug info is unrelated to MetaGraphDef tags; the tag set remains unchanged.