NVIDIA / OpenSeq2Seq

Toolkit for efficient experimentation with Speech Recognition, Text2Speech and NLP
https://nvidia.github.io/OpenSeq2Seq
Apache License 2.0
1.54k stars 372 forks source link

How can I save a model as a pb files so that I can convert the model to tflite? #483

Open yash-saini275 opened 4 years ago

yash-saini275 commented 4 years ago

Hey, I am using the jasper model for speech recognition. Now i want to save the trained model as pb files which I can convert to tflite files which will be served in mobile application. After a bit of work I found that I can use build_trt_forward_pass_graph function which builds the graph and can be used to save the model as pb files but when i try to convert the pb files to tflite files it shows the error that MetaGraphDef doesn't have any tags set which will be used serve the model. I am sure that there is an error while converting the model. Can someone help me about how can i convert the checkpoints to pb files.

feroult commented 4 years ago

Hi @yash-saini275! have you find a solution for your question?

rindrarbz commented 4 years ago

Hello @yash-saini275, I am interested too about your question!

feroult commented 4 years ago

Sorry folks, I managed to save the Graph to PB and I didn't post it here.

I created a gist file with the relevant code.

Basically, the sequence I did was:

  1. Load the model
  2. Call build_trt_forward_pass_graph (it's the only way I could get it working)
  3. Get the right output node
  4. Fix batch norm nodes
  5. Freeze the graph
  6. Save it

Please let me know if you have other ideas and if you try it, share the results with us.

I haven't tried to convert to TF Lite yet.

Regards

rindrarbz commented 4 years ago

Hello @feroult , thank you very much for your answer.

It worked correctly ! I am going to try to use the graph now !

tulasiram58827 commented 4 years ago

@feroult Did u converted it to tflite?