GPU-accelerated Android NDK examples for running TensorFlow Lite computer-vision models on-device. The repository is useful for Android developers evaluating native TFLite GPU Delegate builds for driver-monitoring and ADAS-style prototypes.
Mati_DSMS/: camera-based face detection and face/iris landmark experiments using bundled MediaPipe TensorFlow Lite models.Tarzan_ADAS/: dense depth, segmentation, object detection, and face mesh examples packaged as an Android NDK app.Sahay_ADAS/: additional ADAS app source and assets covering dense depth, detection, segmentation, and face mesh models.third_party/: TensorFlow Lite build scripts and checked-in support code used by the Android app projects.
| Folder | What it contains | Open/build from |
|---|---|---|
Mati_DSMS/ |
Android app com.example.tflite_blazeface with CMake native code and arm64-v8a TensorFlow Lite libraries. |
Open Mati_DSMS/ in Android Studio. |
Tarzan_ADAS/ |
Android app com.example.tflite_iris_landmark with CMake native code and arm64-v8a TensorFlow Lite libraries. |
Open Tarzan_ADAS/ in Android Studio. |
Sahay_ADAS/ |
Native source and assets for ADAS demos; no Gradle project file is checked in under this folder. | Inspect or port Sahay_ADAS/app/src/main/ into an Android app project. |
- Download and install Android NDK.
$ mkdir ~/Android/
$ mv ~/Download/android-ndk-r20b-linux-x86_64.zip ~/Android
$ cd ~/Android
$ unzip android-ndk-r20b-linux-x86_64.zip
- Download and install bazel.
$ wget https://github.com/bazelbuild/bazel/releases/download/3.1.0/bazel-3.1.0-installer-linux-x86_64.sh
$ chmod 755 bazel-3.1.0-installer-linux-x86_64.sh
$ sudo ./bazel-3.1.0-installer-linux-x86_64.sh
- run the build script to build TensorFlow Library
$ mkdir ~/work
$ git clone https://github.com/Akhilesh-Gogikar/TorgTech.git
$ cd TorgTech/third_party/
$ ./build_libtflite_r2.4_android.sh
(Tensorflow configure will start after a while. Please enter according to your environment)
$ ls -l tensorflow/bazel-bin/tensorflow/lite/
$ ls -l tensorflow/bazel-bin/tensorflow/lite/delegates/gpu/
Mati_DSMS includes its model assets in the repository. For the ADAS app
assets, run the downloader that is checked into the target app:
$ cd ~/work/TorgTech/Tarzan_ADAS/app/src/main/assets/model
$ bash download.sh
Sahay_ADAS/app/src/main/assets/model/download.sh is the matching downloader
for the Sahay asset folder when porting that source into an Android app.
- Download and install Android Studio.
- Start Android Studio.
$ cd ${ANDROID_STUDIO_INSTALL_DIR}/android-studio/bin/
$ ./studio.sh
- Install NDK 20.0 by SDK Manager of Android Studio.
- Open one checked-in Android Studio project from the quick build targets table, such as
~/work/TorgTech/Mati_DSMSor~/work/TorgTech/Tarzan_ADAS. - Build and Run.
| Host PC | Target Device |
|---|---|
| x86_64 | arm64-v8a |
| Ubuntu 18.04.4 LTS | Android 9 (API Level 28) |
| Android NDK r20b |