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

Viewed 1311

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 (e.g.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..

The model was trained and saved using the Tensorflow Object Detection API. Is it still possible to convert it to a Keras model? If so, any suggestions?

1 Answers

I faced the same issues while converting YoloV5 to Tensorflow format to deploy a model. you need to use keras=Truein the export command of the model. This will generate the Keras_metadata.pb file at the directory. Please see this link.

Related