简体   繁体   English

Convert a Tensorflow model in SavedModel format (.pb file) saved with tf.saved_model.save to a Keras model (.h5 file)

[英]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.

相关问题 SavedModel 文件不存在于:model.h5/{saved_model.pbtxt|saved_model.pb} - SavedModel file does not exist at: model.h5/{saved_model.pbtxt|saved_model.pb} OSError:SavedModel 文件不存在于:cnnCat2.h5\{saved_model.pbtxt|saved_model.pb} - OSError: SavedModel file does not exist at: cnnCat2.h5\{saved_model.pbtxt|saved_model.pb} OSError:SavedModel 文件不存在于:model/CPN_Model.h5\{saved_model.pbtxt|saved_model.pb} - OSError: SavedModel file does not exist at: model/CPN_Model.h5\{saved_model.pbtxt|saved_model.pb} OSError:SavedModel 文件不存在于:../dnn/mpg_model.h5/{saved_model.pbtxt|saved_model.pb} - OSError: SavedModel file does not exist at: ../dnn/mpg_model.h5/{saved_model.pbtxt|saved_model.pb} OSError:SavedModel 文件不存在于:model\mymodel.h5/{saved_model.pbtxt|saved_model.pb} - OSError: SavedModel file does not exist at: model\mymodel.h5/{saved_model.pbtxt|saved_model.pb} keras.models.save_model 中的 saved_model.pb 是否与 tensorflow freeze_graph output.pb 文件相同? - Is saved_model.pb from keras.models.save_model the same with tensorflow freeze_graph output .pb file? OSError:SavedModel 文件不存在于:/content\model\2016/{saved_model.pbtxt|saved_model.pb} - OSError: SavedModel file does not exist at: /content\model\2016/{saved_model.pbtxt|saved_model.pb} 如何将 .pb 文件转换为 .h5。 (Tensorflow 模型到 keras) - How to convert .pb file to .h5. (Tensorflow model to keras) Tensorflow 2.0 将 keras 模型转换为 .pb 文件 - Tensorflow 2.0 Convert keras model to .pb file OSError:SavedModel 文件不存在于:C:/User/A/model/saved_model.pb - OSError: SavedModel file does not exist at: C:/User/A/model/saved_model.pb
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM