Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSError: SavedModel file does not exist at: main.h5/{saved_model.pbtxt|saved_model.pb} #35909

Closed
niccle27 opened this issue Jan 15, 2020 · 12 comments
Assignees
Labels
comp:keras Keras related issues stat:awaiting response Status - Awaiting response from author TF 1.14 for issues seen with TF 1.14 type:bug Bug

Comments

@niccle27
Copy link

System information

  • Custom code provided below
  • OS Platform and Distribution : Linux Raspbian
  • Raspberry pi
  • TensorFlow installed from apt repos:
  • TensorFlow version (use command below): tensorflow 1.14
  • Python version: python 3

Describe the current behavior
At running, the following line raise the following error:

face_recognition_model = tf.keras.models.load_model('face_recognition_model.h5')

OSError: SavedModel file does not exist at: main.h5/{saved_model.pbtxt|saved_model.pb}
Describe the expected behavior
Expected to load the model for later prediction

Code to reproduce the issue

detection_graph = tf.Graph()
with detection_graph.as_default():
    od_graph_def = tf.GraphDef()
    with tf.gfile.GFile(PATH_TO_CKPT, 'rb') as fid:
        serialized_graph = fid.read()
        od_graph_def.ParseFromString(serialized_graph)
        tf.import_graph_def(od_graph_def, name='')
label_map = label_map_util.load_labelmap(PATH_TO_LABELS)
categories = label_map_util.convert_label_map_to_categories(label_map,
                                                            max_num_classes=NUM_CLASSES,
                                                            use_display_name=True)
category_index = label_map_util.create_category_index(categories)
face_recognition_model = tf.keras.models.load_model('face_recognition_model.h5')

Other info / logs
I provided a snippet to reproduce that error. The all code is using a mobilnet trained by transfer learning to detect faces and a classification network is trained and used on keras for facial recognition. The code is working just fine on my computer and i have absolutely no clue why it's not working on my raspberry pi. I can provide the complete code if it's required.

@oanush oanush self-assigned this Jan 16, 2020
@oanush oanush added comp:keras Keras related issues TF 1.14 for issues seen with TF 1.14 type:bug Bug labels Jan 16, 2020
@oanush
Copy link

oanush commented Jan 16, 2020

@niccle27 ,
Can you please provide complete code to reproduce ?Thanks!

@oanush oanush added stat:awaiting response Status - Awaiting response from author type:bug Bug and removed type:bug Bug labels Jan 16, 2020
@niccle27
Copy link
Author

@oanush
Thanks a lot for trying to help me,

Since it's part of a school project, i wasn't able to have access to the raspberry before now, so basically one more precision : python version i'm using is Python 3.7.3

After further try to limit the code required to reproduce the issue, :

import tensorflow as tf
face_recognition_model = tf.keras.models.load_model('face_recognition_model.h5')

is enough to reproduce the issue, here is the complete Error :

2020-01-16 14:18:22.697745: E tensorflow/core/platform/hadoop/hadoop_file_system.cc:132] HadoopFileSystem load error: libhdfs.so: cannot open shared object file: No such file or directory
Traceback (most recent call last):
File "testBug.py", line 17, in
face_recognition_model = tf.keras.models.load_model('face_recognition_model.h5')
File "/home/pi/Desktop/DLClem/RecognitionInference/venvRecognition/lib/python3.7/site-packages/tensorflow_core/python/keras/saving/save.py", line 149, in load_model
loader_impl.parse_saved_model(filepath)
File "/home/pi/Desktop/DLClem/RecognitionInference/venvRecognition/lib/python3.7/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: face_recognition_model.h5/{saved_model.pbtxt|saved_model.pb}

I'm not using hadoop at all, therefore i don't really know where that line is coming from. I verified and that library isn't present in my Ubuntu 18.04 desktop either (no error message though)

Any idea ?

@tensorflowbutler tensorflowbutler removed the stat:awaiting response Status - Awaiting response from author label Jan 17, 2020
@oanush
Copy link

oanush commented Jan 22, 2020

@niccle27 ,
From the error log i can see that saved_model- face_recognition_model.h5 does not exist, make sure you import the file to the right path and then try loading the model using load_model.
You can provide us the code being used so that i can help you out with the resolving the issue.Thanks!

@oanush oanush added the stat:awaiting response Status - Awaiting response from author label Jan 22, 2020
@niccle27
Copy link
Author

Sorry for the late reply,
I manage to identify the problem, the path was alright. The problem concern the h5py package installed using pip on the raspberry pi. Apparently there seem to be some issue with it. I managed to fix it by installing using the debian repository : sudo apt-get install python3-h5py.

This is indeed irrelevant to tensorflow, therefore the issue can be closed.

Thanks a lot !

@tensorflow-bot
Copy link

Are you satisfied with the resolution of your issue?
Yes
No

@JinkaiGUAN
Copy link

I have the same problem, but after use the install command you mentioned before, it didn't work and get the same error again, i.e., SaveModel file does not exit.

@SKRohit
Copy link

SKRohit commented May 7, 2020

@JinkaiGUAN did u find the solution?

I have the same problem, but after use the install command you mentioned before, it didn't work and get the same error again, i.e., SaveModel file does not exit.

@Jerrrrykun
Copy link

I have just met the same problem when using Cloud9...... (Haven't solved it yet.

@marlexct
Copy link

I have the same problem using my tensorflow (based on 20.08) docker container downloaded from nvidia catalog with TF 2.2.
Error
self.model = load_model(model_path)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/saving/save.py", line 189, in load_model
loader_impl.parse_saved_model(filepath)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/saved_model/loader_impl.py", line 113, in parse_saved_model
constants.SAVED_MODEL_FILENAME_PB))
OSError: SavedModel file does not exist at: ./analytics/models/faceembedding/facenet_keras.h5/{saved_model.pbtxt|saved_model.pb}

I have run this code before and it worked (another environment).

@Jerrrrykun
Copy link

Jerrrrykun commented Oct 12, 2020

I have just met the same problem when using Cloud9...... (Haven't solved it yet.

Well, I have solved this by setting the AWS access key in the virtual environment.... So I think if you are still facing this problem try thinking about the access part!(relative path, access to S3 and so on.)

@noumanaziz7241
Copy link

@Jerrrrykun can you explain how to set the AWS access key. I also have the same problem with my code i.e.
OSError: SavedModel file does not exist at: checkpoints/Test_UCSDped2_Model.h5/{saved_model.pbtxt|saved_model.pb}

@segestic
Copy link

The solution is found here
https://stackoverflow.com/questions/61699140/oserror-savedmodel-file-does-not-exist-at-dnn-mpg-model-h5-saved-model-pbt

import os
whatever = load_model(os.path.join("./dnn/","mpg_model.h5"))

Note. - single dot not double before the slash"/"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:keras Keras related issues stat:awaiting response Status - Awaiting response from author TF 1.14 for issues seen with TF 1.14 type:bug Bug
Projects
None yet
Development

No branches or pull requests

9 participants