Thursday, June 28, 2018

Use TensorFlow python code with android app

Leave a Comment

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?

1 Answers

Answers 1

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 Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment