'Error:MetaGraphDef associated with tags 'serve' could not be found in SavedModel
I have this error
RuntimeError: MetaGraphDef associated with tags 'serve' could not be found in SavedModel. To inspect available tag-sets in the SavedModel, please use the SavedModel CLI: `saved_model_cli`
available_tags: [{'train', 'serve'}]
I did saved_model_cli show --dir ./
, I got
MetaGraphDef with tag-set: 'train, serve' contains the following SignatureDefs:
My source code is
import tensorflow as tf
with tf.Session(graph=tf.Graph()) as sess:
tf.saved_model.loader.load(sess,[tf.saved_model.tag_constants.SERVING],'../export_dir/0/')
graph = tf.get_default_graph().as_graph_def()
with tf.gfile.GFile('./frozen.pb', "wb") as f:
f.write(graph.SerializeToString())
When I search this problem solution, I saw "Use [tf.saved_model.tag_constants.SERVING]", but I cannnot solve this problem...
Solution 1:[1]
This error message is telling you that the output tensor name you specified is not found in the saved model.
If all your installations go well, you should have access to use the saved_model_cli
handy from anywhere in the terminal.
To see your output tensor names, simply run the command
saved_model_cli show --dir /path/to/saved/model --all
You can also check for more reference here
Solution 2:[2]
You seem to have what is called a frozen graph. Those cannot be converted, nor do they have a graph definition. See this discussion for a detailed answer.
For comparison with a saved model (with graph definition) where a conversion works, see this hello_world example from Tensorflow Lite Micro. When you either train the model yourself based on the provided Jupyter notebook or download the hello_world.zip you get saved_model.pb. Enter the directory where this file is located, models/model
and type
saved_model_cli show --dir ./ --all
then you get a long list of information. Or either
saved_model_cli show --dir=./
you get
The given SavedModel contains the following tag-sets: 'serve'
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | SirPhemmiey |
Solution 2 |