I have written a script for sequence classification using TensorFlow in Python. I would like to port this code to Android. I have seen the example on the TensorFlow github page
The 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 an app using the JNI to call the C++ TensorFlow API (see a complete example here).
When you build your graph in Python, you should take note of the names of the tensors that will represent (i) the input data to be classified, and (ii) the predicted output values. Then you will be able to run a step by feeding a value for (i), and fetching the value for (ii).
One final concern is how to represent the model parameters in your exported graph. There are several ways to do this, including shipping a TensorFlow checkpoint (written by a tf.train.Saver) as part of your app, and running the restore ops to reload it. One method, which has been used in the released InceptionV3 model is to rewrite the graph so that the model parameters are replaced with "Const"
nodes, and the model graph becomes self contained.
There is QPython or Kivy.
QPython - Android Apps on GooglePlay. It's a script engine that runs Python on android devices. It lets your android device run Python scripts and projects. It contains the Python interpreter and some other stuff like pip
, but there's no compiler available, so only pure-python packages will work.
Python for Android - lets you compile a Python application into an Android APK together with additional packages both pure-python and those that need compiling.