简体   繁体   中英

How can I use the model.ckpt Files from Tensorflow Training on Google Cloud for making predictions?

I am using Tensorflow 1.15 and Python 3.7 and I am a beginner. I trained a tensorflow model with my own dataset on google cloud as described here: https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/tf1_training_and_evaluation.md

After training my google cloud bucket had listed the model.ckpt files. I saved the model as described here: https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/exporting_models.md . Doing this generated some files: checkpoint, frozen_inference_graph.pb, model.ckpt.data-00000-of-00001, model.ckpt.index, model.ckpt.meta, pipeline.config and a folder "saved_model" which contains a file saved_model.pb and an empty variables folder. So far so good. Now I wanted to use these files to make predictions using this notebook: https://colab.research.google.com/github/tensorflow/models/blob/master/research/object_detection/colab_tutorials/object_detection_tutorial.ipynb but I stuck at the "load object detection model" section, I always get this

OSError: SavedModel file does not exist at: home/user/models/research/exported_graphs/saved_model/{saved_model.pbtxt|saved_model.pb}

What am I doing wrong? I tried all the possibilities and read dozens of stackoverflow articles but I can't find any usable solution. Is there any other possibility to use the model.ckpt files which were generated by training to make a .h5 / make predictions?

Thank you very much in advance!

Firstly upload saved_model on Google_cloud, and use below code snippet to load saved_model .

def load_model(model_name):
  #path to model directory
  model_dir = "model_directory"

  model_dir = pathlib.Path(model_dir)/"saved_model"

  model = tf.saved_model.load(str(model_dir))

  return model

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM