Skip to content

Handwritten digits classification from MNIST with TensorFlow on Android; Featuring Tutorial!

Notifications You must be signed in to change notification settings

llSourcell/mnist-android-tensorflow

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MNIST on Android with TensorFlow

Check the video demo here

Image Beautiful edition, I know.

Handwritten digits classification from MNIST on Android with TensorFlow.

If you want to make your own version of this app or want to know how to save your model and export it for Android or other devices check the very simple tutorial bellow.

The UI and expert-graph.pb model were taken from: https://github.com/miyosuda/TensorFlowAndroidMNIST, so thank you miyousuda.

If you have no ideia what I just said above, have a look on the instructions bellow.

How to run this?

Just open this project with Android Studio and is ready to run, this will work with x86 and armeabi-v7a architectures.

How to export my model?

A full example can be seen here

  1. Train your model

  2. Keep an in memory copy of eveything your model learned (like biases and weights) Example: _w = sess.eval(w), where w was learned from training.

  3. Rewrite your model changing the variables for constants with value = in memory copy of learned variables. Example: w_save = tf.constant(_w)

    Also make sure to put names in the input and output of the model, this will be needed for the model later. Example:
    x = tf.placeholder(tf.float32, [None, 1000], name='input')
    y = tf.nn.softmax(tf.matmul(x, w_save) + b_save), name='output')

  4. Export your model with:
    tf.train.write_graph(<graph>, <path for the exported model>, <name of the model>.pb, as_text=False)

How to run my model with Android?

You need tensorflow.aar, which can be downloaded from the nightly build artifact of TensorFlow CI, here we use the #124 build.

Interacting with TensorFlow

To interact with TensorFlow you will need an instance of TensorFlowInferenceInterface, you can see more details about it here

Thank you, have fun!

About

Handwritten digits classification from MNIST with TensorFlow on Android; Featuring Tutorial!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages

  • Java 70.0%
  • Python 30.0%