TensorFlow port code for Android

I wrote a script to classify sequences using TensorFlow in Python. I would like to port this code to Android. I saw an example on the github TensorFlow page regarding Android, but for images.

Is there a way to directly connect my TensorFlow Python code on Android?

+6
source share
2 answers

A typical way to do this is to build (and train) your model using Python, save the GraphDef proto to a file using tf.train.write_graph() , and then write the application using JNI to call the C ++ TensorFlow API (see full example here ).

When you plot your graph in Python, you must take into account the names of the tensors that will represent (i) the input data to be classified, and (ii) the predicted output values. You can then complete the step by loading the value for (i) and selecting the value for (ii).

One of the last issues is how to present the model parameters in the exported graph. There are several ways to do this, including delivering a TensorFlow breakpoint (written by tf.train.Saver ) as part of your application and running ops recovery to restart it. One of the methods that was used in the released InceptionV3 model is to rewrite the graph so that the model parameters are replaced by "Const" nodes and the model graph becomes autonomous.

+6
source

There is QPython or Kivy .

QPython - Android Application on GooglePlay . This is a script engine that runs Python on Android devices. This allows your Android device to run Python scripts and projects. It contains a Python interpreter and some other things like pip , but no compiler, so only pure-python packages will work.

Python for Android - allows you to compile a Python application in the Android APK along with additional packages of pure-python, as well as those that require compilation.

0
source

All Articles