A very specific question!
You're looking for the TensorFlow Lite (TFLite) version and the corresponding tfops version for Android dependency.
Here's the breakdown:
TensorFlow Lite (TFLite) versions
TFLite is a part of the TensorFlow project, and its versions are tied to the TensorFlow releases. You can find the TFLite versions in the TensorFlow Release Notes. I'll summarize the relevant versions for Android:
| TensorFlow Version | TFLite Version | Android Support |
|---|
| 2.8.0 | 2.8.0 | Android 5.0 (API 21) and above |
| 2.7.0 | 2.7.0 | Android 5.0 (API 21) and above |
| 2.6.0 | 2.6.0 | Android 5.0 (API 21) and above |
| 2.5.0 | 2.5.0 | Android 5.0 (API 21) and above |
| 2.4.0 | 2.4.0 | Android 5.0 (API 21) and above |
| 2.3.0 | 2.3.0 | Android 5.0 (API 21) and above |
TF Ops (TensorFlow Ops) versions
tfops is a part of the TensorFlow Lite Support Library, which provides additional operations (ops) for TFLite models. The tfops version is independent of the TFLite version, but it's built on top of TFLite. Here are the tfops versions compatible with the above TFLite versions:
| TFLite Version | TF Ops Version |
|---|
| 2.8.0 | 0.3.0 |
| 2.7.0 | 0.2.0 |
| 2.6.0 | 0.1.0 |
| 2.5.0 | 0.0.3 |
| 2.4.0 | 0.0.2 |
| 2.3.0 | 0.0.1 |
Android Dependency (Gradle)
Now, let's get to the Android dependency part. You'll need to add the following dependencies to your build.gradle file (Module level):
For TFLite ( choose one of the versions above ):
dependencies {
implementation 'org.tensorflow:tensorflow-lite:2.8.0' // or 2.7.0, 2.6.0, etc.
}
For TF Ops (optional, but recommended for additional ops support):
dependencies {
implementation 'org.tensorflow:tensorflow-lite:2.8.0'
implementation 'org.tensorflow:tensorflow-lite-support:0.3.0' // tfops version matching TFLite 2.8.0
}
If you're using Android NDK ( native code ), you'll also need:
android {
...
defaultConfig {
...
ndk {
abiFilters 'armeabi-v7l', 'arm64-v8a', 'x86', 'x86_64'
}
}
}
dependencies {
implementation 'org.tensorflow:tensorflow-lite:2.8.0'
implementation 'org.tensorflow:tensorflow-lite-gpu:2.8.0' // for GPU acceleration (optional)
implementation 'org.tensorflow:tensorflow-lite-support:0.3.0'
}
Tips:
- Match the versions: Ensure the TFLite and TF Ops versions are compatible (as shown in the tables above).
- Check Android API level: Verify your Android app's
targetSdkVersion and minSdkVersion are compatible with the chosen TFLite version (e.g., API 21+ for TFLite 2.3.0 and above).
- GPU acceleration (optional): If you want to leverage GPU acceleration, add the
tensorflow-lite-gpu dependency (as shown above).
- Use the latest stable versions: Unless you have a specific reason, use the latest stable TFLite and TF Ops versions (currently 2.8.0 and 0.3.0, respectively).
Now, you're all set! Your Android app should be able to use TensorFlow Lite with the selected version and TF Ops support.
Happy coding!