1

I am trying to convert my model in file (.pb) format to file (.h5) format. I tried following the link below: Tensorflow (.pb) format to Keras (.h5)

Below is the code that I wrote:

import tensorflow as tf
import os
facenet_model = tf.keras.models.load_model('./model_data/20180402-114759/')
tf.keras.models.save_model(facenet_model, 'New_Model.h5') # Saving the Model in H5 Format
loaded_model_from_h5 = tf.keras.models.load_model('New_Model.h5') # Loading the H5 Saved Model
print(loaded_model_from_h5.summary())

In addition to the 20180402-114759.pb file, as shown in the screenshot below: enter image description here

This is what happened:

Traceback (most recent call last):
  File "test_facenet.py", line 25, in <module>
    facenet_model = tf.keras.models.load_model('./model_data/20180402-114759/')
  File "C:\Users\hai.nguyendinhkhanh\.conda\envs\py36\lib\site-packages\tensorflow_core\python\keras\saving\save.py", line 146, in load_model
    loader_impl.parse_saved_model(filepath)
  File "C:\Users\hai.nguyendinhkhanh\.conda\envs\py36\lib\site-packages\tensorflow_core\python\saved_model\loader_impl.py", line 83, in parse_saved_model
    constants.SAVED_MODEL_FILENAME_PB))
OSError: SavedModel file does not exist at: ./model_data/20180402-114759//{saved_model.pbtxt|saved_model.pb}

Aryan
  • 3,338
  • 4
  • 18
  • 43
  • Error says file does not exit. can you change the saved file name 20180402-114759 to 20180402_114759. and also try to provide full path. Thanks! –  Dec 23 '20 at 07:12
  • How about removing the slash in the end? There is a double slash in the error message. – Kirk Mar 02 '21 at 17:03

0 Answers0