2

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?

insects56
  • 21
  • 2
  • Does [this](https://stackoverflow.com/questions/65609942/how-to-save-tensorflow-2-object-detection-model-including-all-weights) reference help you to solve this issue? –  Jan 14 '22 at 19:02
  • have you got the answer? because I'm also finding it. – parth panchal Mar 03 '22 at 07:00

1 Answers1

0

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.

user3503711
  • 1,623
  • 1
  • 21
  • 32
Sri146
  • 1
  • Thanks for the reply. I am trying to convert the saved_model to h5. Is that possible? I loaded it using tf.keras.models.load_model and when I try to save using tf.keras.models.save_model() I get: Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python3.8/dist-packages/keras/utils/traceback_utils.py", line 67, in error_handler raise e.with_traceback(filtered_tb) from None File "/usr/local/lib/python3.8/dist-packages/keras/saving/saved_model/load.py", line 1071, in get_config raise NotImplementedError NotImplementedError – Javier Naranjo Alcázar Nov 08 '22 at 14:09