models icon indicating copy to clipboard operation
models copied to clipboard

need to Deploy Object detection models to tensorflow servings.

Open aashish-0393 opened this issue 7 years ago • 9 comments

I need to convert Model trained on Object detection API to tensorflow servings. The folder structure I get from saving a Object Detection model is :: model --checkpoint --frozen_inference_graph.pb --model.ckpt.data-00000-of-00001 --model.ckpt.index --model.ckpt.meta --pipeline.config --saved_model --saved_model.pb --variables --(empty)

I need to convert above to tensorflow serving model structure

aashish-0393 avatar Feb 05 '19 10:02 aashish-0393

Hi Aashish - I wrote a post around deploying object detection models using TF Serving. It might help you.

https://medium.freecodecamp.org/how-to-deploy-an-object-detection-model-with-tensorflow-serving-d6436e65d1d9

gauravkaila avatar Feb 11 '19 15:02 gauravkaila

@gauravkaila is this post up to date? it was written in 2017 so I imagine a lot has changed.

austinmw avatar Apr 09 '19 03:04 austinmw

@austinmw I am not maintaining the post anymore, though the content of the post is still very relevant in terms of how TF-Serving works. You might want to refer to the TF Serving docs by TF (https://www.tensorflow.org/tfx/serving/serving_basic) which is (now) very well written.

gauravkaila avatar Apr 09 '19 08:04 gauravkaila

@gauravkaila thanks. I ask because my object detection job directly outputed export/Servo/ with variables contents already. I successfully launched a server running the model, but now I'm stuck on the last step of figuring out what the default input format should be to convert an image and send it to the server. It seems that it's looking for a string input type.

austinmw avatar Apr 09 '19 18:04 austinmw

@austinmw how do you fix the problem: folder of variables is empty. rewrite the method of _write_saved_model ,but does not work out.

w279805299 avatar Apr 11 '19 07:04 w279805299

@w279805299 use the method of rewriting write_saved_model inside exporter.py, but instead of creating a new script to call exporter.py, run export_inference_graph.py from the command line which ends up calling exporter.py. Trying to use exporter.py directly gave me tf session issues.

TF obj det will automatically call export_inference_graph.py at the end of training, but the input type they use is tf_example instead of what you probably want with input_tensor

Also don't just completely overwrite exporter.py with the example from that page, just replace the parts that are needed.

austinmw avatar Apr 11 '19 15:04 austinmw

@austinmw can you share the modified export.py you used? I modified the write_saved_model inside exporter.py , used export_inference_graph.py to export, it resulted in below error:

_File "C:\Anaconda3\lib\site-packages\tensorflow\python\framework\importer.py", line 94, in ProcessGraphDefParam raise TypeError('graph_def must be a GraphDef proto.') TypeError: graph_def must be a GraphDef proto.

I am not able to figure its cause, if possible could please share your modified exporter.py.

ashwini-git avatar May 01 '19 19:05 ashwini-git

Hi There, We are checking to see if you still need help on this, as this seems to be an old issue. Please update this issue with the latest information, code snippet to reproduce your issue and error you are seeing. If we don't hear from you in the next 7 days, this issue will be closed automatically. If you don't need help on this issue any more, please consider closing this.

tensorflowbutler avatar Mar 18 '20 21:03 tensorflowbutler

@gauravkaila The latest scipts seem to save the variables and assets etc. Not tested but it should work out of the box then right. Did you happen to test it out ?

mohammedayub44 avatar Apr 05 '21 23:04 mohammedayub44