简体   繁体   中英

converting pretrained tensorflow models for tensorflow serving

I'm trying to use tensorflow serving. However, any of the pretrained models that are available for download (like from here: the TF detection zoo ) don't have any files in the saved_models/variables directory that is required by the serving model.

How do you create the files required in the saved_models/variables directory using the pretrained models available from the detection model zoo?

There is some information from the official documentation , but it doesn't cover my use case of converting a pretrained model to be served.

Other things I've tried is to use the tensorflow serving examples. However, most of the existing documentation uses the Resent implementation as an example, and the pretrained model for resnet has been removed by Tensorflow. This is the linked that tutorials use , note that there's no direct link to download the models. As an aside, but an additional funsy, the python examples in the Tensorflow Serving repo don't work with Tensorflow 2.0.

It appears that this link may be useful in the conversion: https://github.com/tensorflow/models/issues/1988

Ok, as of the time of writing the object detection tutorials only support tensorflow 1.12.0.

It's a little difficult to do this because it's so multitiered, but you need to:

  1. clone the tensorflow open model zoo
  2. patch the models/research/object_detection/exporter.py according to these instructions . Alternatively, you can use this patch which are the aforementioned instructions.
  3. Follow the object detection installation instructions as found here in your cloned repo. It's important to both follow the protobuf compilation steps AND update your python path for the slim libraries .
  4. Follow the instructions for exporting a trained model for inference . Note that the important part of the instruction that is important is that the downloaded model will come will three model.ckpt filenames. The filename that needs to be passed into the exporting script is the base filename of these three filenames. So if the three files are /path/to/model.ckpt.data-00000-of-00001 , /path/to/model.ckpt.meta , and /path/to/model.ckpt.index , the parameter to pass into to the script is: /path/to/model.ckpt
  5. Enjoy your new 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