Saving/Transmitting Model - TensorFlow Lite Transfer Learning on Android

Viewed 137

I am trying to create a pair of Android apps: one which trains an image classification transfer-learning model and one which simply uses the trained model for inference. These apps would run on separate devices, and the usefulness would lie in training the model on a more-powerful device and being able to perform inference with that model on a less-powerful wearable device. Transfer learning is being implemented as explained in the post here: https://blog.tensorflow.org/2019/12/example-on-device-model-personalization.html.

The problem is I cannot find a good way to save and transmit the trained model from the first device to the second. I have tried implementing serialization for Bluetooth transmission, but the Android TFL library is not easy to make serializable. How difficult would it be to somehow save a .tflite file on Android? Does this feature already exist and I have missed it? Any help or ideas would be greatly appreciated. Thank you!

1 Answers

For transferring the model, you should do this as a binary instead of trying to explicitly serialize/deserialize. There are a number of different libraries available for this on Android, so it shouldn't be too difficult to find something that works for your app.

As for loading the TFLite model itself and running inference, it's possible to do this device-local using the TFLite Interpreter class and simply pointing it at your on-device file. You can find an example of this here: https://www.tensorflow.org/lite/inference_with_metadata/lite_support

Related