Android Studio is a powerful tool for building Android Apps and is an ideal platform for Android Development. Building a set of Deep Learning Android demo applications - TF Classify, TF Detect, TF Speech, TF Stylize, TFLite Camera Demo - using TensorFlow Lite and Android Studio is as easy as these four steps:
Import the tensorflow directory: https://github.com/tensorflow/tensorflow as a new Android Studio Project.
Enter the URL: https://github.com/tensorflow/tensorflow and hit Clone to download the quantized TensorFlow Lite Model. Install the necessary Gradle extensions as requested during the unzipping process.
Once the necessary changes have been made to the App files, build the App under Build>Build Bundle(s)/APK(s)>Build APK(s)
After the App is successfully built, it can be found in this location ready for use on your Android Smartphone: C:\Users\<User_name>\StudioProjects\tensorflow\tensorflow\lite\java\demo\app\build\outputs\apk
Recommended : Android SDK > 26 and NDK > 14
TensorFlow Lite is a lightweight solution which enables machine learning inference with a low latency on mobile phones and other embedded devices. Released by Google in 2017, it is available on Android, iOS and Raspberry Pi. It has since been constantly evolving to provide better portability for smaller models with an unnoticeable trade off in accuracy. The steps below outline an overview of how a simple deep learning application can be easily deployed onto a mobile phone.
Based on the design of the application to be deployed, one can either choose a pre-trained model or build a custom model to suit the requirements of the app. Since TFLite is currently in its nascent stage, it may prove difficult for it to perform well for custom built models when compared to pre-trained ones. Some models which are compatible with TFLite are Yolo, InceptionV3 and MobileNet.
'TensorFlow Lite Optimizing Converter' or tflite_convert is then used to convert the built model into a TFLite format. This program prunes the unused graph nodes and further optimizes the model.
Once the TFLite model is ready, it can be easily deployed on a mobile phone or any embedded device. The steps vary for Android, iOS and Raspberry Pi. For Android applications, the tool Android Studio is used for the deployment purpose.