-
Notifications
You must be signed in to change notification settings - Fork 4k
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
TF Lite support #1224
Comments
Working on TF Lite is actually on the roadmap, as you can infer from #1213, but still, I have not yet had time to actually to it, so thanks for the feedback. Model changes can be hard, I agree. |
@reuben So, working with
|
Sounds like the same problem as XLA. Variable sequence lengths cause us to depend on Select, and we use VariableV2 and Assign to store and update the RNN state. Both are can be worked around with some effort. |
During latest experiments, we endup being only blocked by the lack of TensorFlowMinimum. According to tensorflow/tensorflow#17289 this was fixed upstream. We should give it a new try. |
So, are the |
@JaviBonilla Looks like they were removed by the streaming model :) |
Porting Deepspeech model to android I am trying to convert the deepspeech model output_graph.pb to tflite using toco using the below command bazel-bin/tensorflow/contrib/lite/toco/toco --input_file=output_graph.pb --output_file=output_graph_fr.tflite --input_format=TENSORFLOW_GRAPHDEF --output_format=TFLITE --inference_type=QUANTIZED_UINT8 --input_array=input_node --output_array=output_node --allow_custom_ops i am using the deepspeech model from the link https://github.com/mozilla/DeepSpeech i get the following error 2018-08-30 16:52:09.853405: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1366] Converting unsupported operation: Equal i have few questions and i have tried the following experiments: a)Error thrown for operator relu is supposed to be coming form tooling_util.cc from the function "CheckIsReadyForQuantization", line 1590. the relu operator is not getting the input from the graph. is there any default min max value we should specify or enable some datatype for the operator. b)Some of the operators are not supported by the TensorFlowLiteRuntime Like CTCBeamSearchDecoder,Enter ,TensorArrayV3 etc. I suppose all these have to be supported by the tensorflow so that the tflite model is converted & inferenced successfully. Is there a reference on how to add these operators, or any guideline or help possible to add a custom operator. c) i also tried this experiment. i used the quantize_weights and allow_custom_ops flags and built the tflite model for deepspeech using the below command : bazel-bin/tensorflow/contrib/lite/toco/toco --input_file=output_graph.pb --output_file=output_graph_fr.tflite --input_format=TENSORFLOW_GRAPHDEF --output_format=TFLITE --inference_type=FLOAT --input_array=input_node --output_array=output_node --allow_custom_ops --quantize_weights This went ahead and build the tflite model for the deepseech even though it showed the log "converting unsupported operation". After i port the tflite model in java classifier and run, i get the below error: Mapped Bytebuffer is not a valid flatbuffer model. Hence we are back to enabling these operators. Any help or direction in this regard will be appreciated. |
The streaming model with a few modifications only has supported OPs, but it runs into this problem: tensorflow/tensorflow#21924 We're actively looking into TFLite support. |
Thanks reuben. what is the difference between the streaming model and the original ds model ?? is it just that the unsupported ops have been removed or are they handled in any other way?? |
@sshabana The core difference is that the streaming model is now a RNN and not a BRNN. Thus it no longer requires the entire audio clip to start processing. |
Thanks kdavis. Does this change of model to RNN imply that the operators which were not supported does not have to enabled any more ?? And thus making it suitable to implement the Tflite model easily ??we are really interested to get this working on our Android based development kit. |
@sshabana Yes this exactly what it implies. However, it runs in to the problem @reuben mentioned above. We are also very interested in making this work on our Android based development kit too. If you have any insight on tensorflow/tensorflow#21924 it will help us both! |
hey kdavis, even with the tflite deepspeech streaming model, i am still seeing the issue in java classifier i get the below error: Mapped Bytebuffer is not a valid flatbuffer model. Now that all operators are enabled on a streaming model, why shd we have such issues. Any insights in this will be helpful. Thanks |
You are passing the wrong kind of model, according to the error. |
Test run on Pixel 2 device:
|
But
|
Lots of roadblocks on
|
It's not yet complete enough to close that bug, but #1687 will allow to directly export from training a model that is ready for TF Lite. Still have to run it through |
With #1690 it will directly export as |
@farwayer You can now just train and |
We have tooling to export, and we have TF Lite available for Android builds now. Support is still early, no CI or anything, this will come later. But the feature is here. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
I tried to convert pb to tflite format but look like current model uses some operations unsupported in TF Lite:
bazel-bin/tensorflow/contrib/lite/toco/toco --input_file=/mnt/data/dev/tf-data/output_graph.pb --input_format=TENSORFLOW_GRAPHDEF --output_format=TFLITE --output_file=/tmp/out.lite --output_arrays=logits --input_arrays=input_lengths,input_node
Some of the operators in the model are not supported by the standard TensorFlow Lite runtime. If you have a custom implementation for them you can disable this error with --allow_custom_ops. Here is a list of operators for which you will need custom implementations: CAST, Enter, Exit, ExpandDims, Fill, LoopCond, Range, ReverseSequence, SPLIT, Select, Stack, TensorArrayGatherV3, TensorArrayReadV3, TensorArrayScatterV3, TensorArraySizeV3, TensorArrayV3, TensorArrayWriteV3, TensorFlowGreaterEqual, TensorFlowLess, TensorFlowMerge, TensorFlowMinimum, TensorFlowShape, TensorFlowSwitch.
It can be hard but IMO adaptation model to TF Lite is necessary for using DeepSpeech on low resource devices such as mobile devices.
The text was updated successfully, but these errors were encountered: