Coder Social home page Coder Social logo

nemiar / tensorflowandroidmnist Goto Github PK

View Code? Open in Web Editor NEW

This project forked from miyosuda/tensorflowandroidmnist

0.0 0.0 0.0 147.1 MB

Tensorflow MNIST demo on Android

Java 0.22% Makefile 0.10% C++ 46.50% Python 38.71% C 0.72% CMake 0.15% Objective-C 0.02% Objective-C++ 0.19% Shell 0.97% Protocol Buffer 0.49% Jupyter Notebook 7.19% HTML 2.11% JavaScript 0.05% TypeScript 2.56% CSS 0.01%

tensorflowandroidmnist's Introduction

TensorFlowAndroidMNIST - Android MNIST demo with TensorFlow

This is a demo app for Android with Tensorflow to detect handwritten digits.

image

This Android demo is based on Tensorflow tutorial.

MNIST For ML Beginners https://www.tensorflow.org/versions/r0.10/tutorials/mnist/beginners/index.html

Deep MNIST for Experts https://www.tensorflow.org/versions/r0.10/tutorials/mnist/pros/index.html

How to train model.

Training scripts for neural network model are located at

https://github.com/miyosuda/TensorFlowAndroidMNIST/tree/master/trainer-script

To create model by yourself, install Tensorflow and run python scripts like

$ python beginner.py

or

$ python expert.py

and locate exported .pb file to assets dir.

To export training model, I added some modification to original tutorial scripts.

Now Tensorflow cannot export network graph and trained network weight Variable at the same time, so we need to create another graph to export and convert Variable into constants.

After training is finished, converted trained Variable to numpy ndarray.

_W = W.eval(sess)
_b = b.eval(sess)

and then convert them into constant and re-create graph for exporting.

W_2 = tf.constant(_W, name="constant_W")
b_2 = tf.constant(_b, name="constant_b")

And then use tf.train.write_graph to export graph with trained weights.

How to build JNI codes

Native .so files are already built in this project, but if you would like to build it by yourself, please install and setup NDK.

First download, extract and place Android NDK.

http://developer.android.com/intl/ja/ndk/downloads/index.html

And then update your PATH environment variable. For example,

export NDK_HOME="/Users/[your-username]/Development/android/android-ndk-r11b"
export PATH=$PATH:$NDK_HOME

And build .so file in jni-build dir.

$ cd jni-build
$ make

and copy .so file into app/src/main/jniLibs/armeabi-v7a/ with

$ make install

(Unlike original Android demo in Tensorflow, you don't need to install bazel to build this demo.

Tensorflow library files (.a files) and header files are extracted from original Tensorflow Android demo r0.10.

tensorflowandroidmnist's People

Contributors

miyosuda avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.