[英]Convert a Tensorflow model in SavedModel format (.pb file) saved with tf.saved_model.save to a Keras model (.h5 file)
I'm trying to convert a Tensorflow object detection model that's saved in a SavedModel format (in a folder with .pb
file, assets
folder, and variables
folder) to Keras.h5 for simpler inference. I'm trying to convert a Tensorflow object detection model that's saved in a SavedModel format (in a folder with
.pb
file, assets
folder, and variables
folder) to Keras.h5 for simpler inference. However, trying common StackOverflow answers to this question (eg this ) results in a ValueError: Unable to create a Keras model from this SavedModel. This SavedModel was created with tf.saved_model.save, and lacks the Keras metadata.Please save your Keras model by calling model.save or tf.keras.models.save_model.
但是,尝试对此问题的常见 StackOverflow 答案(例如this )会导致
ValueError: Unable to create a Keras model from this SavedModel. This SavedModel was created with tf.saved_model.save, and lacks the Keras metadata.Please save your Keras model by calling model.save or tf.keras.models.save_model.
ValueError: Unable to create a Keras model from this SavedModel. This SavedModel was created with tf.saved_model.save, and lacks the Keras metadata.Please save your Keras model by calling model.save or tf.keras.models.save_model.
. .
The model was trained and saved using the Tensorflow Object Detection API. model 使用 Tensorflow Object 检测 ZDB974238714CA8A1434A7CE1D08 进行训练和保存。 Is it still possible to convert it to a Keras model?
是否仍然可以将其转换为 Keras model? If so, any suggestions?
如果是这样,有什么建议吗?
I faced the same issues while converting YoloV5 to Tensorflow format to deploy a model.在将 YoloV5 转换为 Tensorflow 格式以部署 model 时,我遇到了同样的问题。 you need to use
keras=True
in the export command of the model.您需要在 model 的导出命令中使用
keras=True
。 This will generate the Keras_metadata.pb file at the directory.这将在目录中生成 Keras_metadata.pb 文件。
[https://www.tensorflow.org/api_docs/python/tf/keras/models/save_model][1] [https://www.tensorflow.org/api_docs/python/tf/keras/models/save_model][1]
[1]: please refer this link for adding above commands to save Tensorflow model. [1]:请参考此链接添加上述命令以保存 Tensorflow model。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.