Reputation: 622
I am trying to use TensorFlow in my android app. But the .so file is little bit larger than needed, is there a way to reduce libtensorflow_inference.so size?
Link TensorFlow-Android-Inference
Upvotes: 3
Views: 2853
Reputation: 25673
I don't know how to reduce the size of the .so files, but there is a way to save huge amounts of space by making it possible to compress the TensorFlow model. See this excellent blog post by Pete Warden for more details.
In summary, you can use optimize_for_inference
and quantize_graph
to make it possible to compress a 87MB model to 24MB (you'll see this space saving when building the APK).
Upvotes: 0
Reputation: 331
In addition to selective registration, you can try passing -c opt
to bazel. For me this takes the uncompressed .so size from 24mb -> 13mb, and compressed from 5.5mb -> 4.4mb.
Upvotes: 3
Reputation: 2878
There's no good guide to doing this yet, but you can start by removing unneeded ops using the print_selective_registration_header script: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/tools/print_selective_registration_header.py
This needs to be documented more extensively.
Upvotes: 5