I currently have TensorFlow code in python and are trying to find the best way to add this to an android app. As I see it there are a few options to do this.
I've been looking at ML kit (https://developers.google.com/ml-kit/). But I'm not sure if this would work since I am using some specific TensorFlow functions to make calculations in the graph. For example these two lines:
t_score = tf.reduce_mean(t_obj)
t_grad = tf.gradients(t_score, t_input)[0]
Would that be possible to do with ML kit?
Another option would then be to use TensorFlow (lite) for Java without ML kit, but looking at the Java API it seems to be limited, would those two calls above be possible to do in java?
The last option would be to host the python code and use it as backend so that the Android app could send the data to it and receive the result. That would be more expensive since the computations can't be made on mobile. So if possible the other options are preferred.
How would you do this?
TensorFlow Lite lets you run TensorFlow machine learning (ML) models in your Android apps. The TensorFlow Lite system provides prebuilt and customizable execution environments for running models on Android quickly and efficiently, including options for hardware acceleration.
TensorFlow Mobile is used for a mobile platform such as iOS and Android.
Python can be used for Android App Development even though Android doesn't support native Python development. This can be done using various tools that convert the Python apps into Android Packages that can run on Android devices.
Run machine learning models in your Android, iOS, and Web apps. Google offers a range of solutions to use on-device ML to unlock new experiences in your apps. To tackle common challenges, we provide easy-to-use turn-key APIs.
I have done a similar code lab from Google. So, I'm sharing working demos of your problem:
1.) https://codelabs.developers.google.com/codelabs/tensorflow-style-transfer-android/index.html?index=..%2F..%2Fio2017#0
2.) https://codelabs.developers.google.com/codelabs/tensorflow-for-poets-2/#0
3.) https://codelabs.developers.google.com/codelabs/tensorflow-for-poets-2-tflite/#0
Hope, it helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With