A Guide to Running Tensorflow Models on Android
Why Stack Overflow recommends it
Stack Overflow users link it when asking or answering how to export a trained Keras or TensorFlow model and run it inside an Android app.
Recommended by 3 people across 3 different months, 2017 to 2020.
What it is
A 48-minute tutorial by Siraj Raval that builds an Android app which recognizes hand-drawn MNIST digits using a pre-trained TensorFlow model. It walks through Android Studio and the Gradle build to load a frozen .pb graph and run inference on the device, with code on GitHub.
What people said
Recommends Shubham Bansal · 2018-01 · Stack Overflow · on “Tensorflow on android: directly build app in python?”
You can create your tensorflow model on your desktop and save it as a .pb file. Then you can add this model to your android project and make use of it to make predictions on the android device. Its like training(which involves heavy computations) on a desktop machine(which is more powerful) and using the model to make predictions(which involves less computations) on a mobile device(comparatively less powerful). This is a link to a great video by Siraj Raval [this video]
Recommends Kenan · 2020-01 · Stack Overflow · on “How do I implement keras mnist model with video camera”
Your question is very broad however there might be one video to answer all your qestions. This [this video] is how use an ml model on your Android.
Recommends Enzio · 2020-02 · Stack Overflow · on “"IndexError: list index out of range" error when calling tensorflow freeze_graph”
I have a fine tuned vgg16 model trained with keras. I want to use the model in Android. Was following this [this video] tutorial and the first step is to convert the keras model into a Tensorflow pb file format. These are the layer names in my model layer_names=[layer.name for layer in model.layers] print(layer_names) output 'input_1', 'block1_conv1', 'block1_conv2', 'block1_pool', 'block2_conv1', 'block2_conv2', 'block2_pool', 'block3_conv1', 'block3_conv2', 'block3_conv3', 'block3_pool', 'block4_conv1', 'block4_conv2', 'block4_conv3', 'block4_pool', 'block5_conv1', 'block5_conv2', 'block5_conv3', 'block5_pool', 'flatten', 'dense_1', 'dropout_1', 'dense_2'] I use this function to convert the ker
Cites Bhagyashri Sarvate · 2017-09 · Stack Overflow · on “How to use a trained keras model to do classification in an android application”
I am new to keras. But even I am trying to build a similar application by training the model in keras and developing an android app. I came across Siraj Raval's youtube video. [this video] You need to save the weights in .pb files and export the model to android. Please check if it is of any help.
Cites Marcell Molnár · 2019-01 · Stack Overflow · on “Grayscale image classification with neural network on Android with OpenCV”
I'm working on and android app that can digitize numbers from a paper. I use native OpenCV code to find the numbers on the image. After that I want to use OpenCV's dnn module to recognise the number. A nice tutorial on creating the neural net can be found here: [this video] The mnist_convnet_graph.pbtxt begins with this: node { name: "conv2d_1_input" op: "Placeholder" attr { key: "dtype" value { type: DT_FLOAT } } attr { key: "shape" value { shape { dim { size: -1 } dim { size: 28 } dim { size: 28 } dim { size: 1 } } } } } So the input is a 28x28 grayscale image. In the tutorial java code is used to use the neural net. However, I would like to use it in C++, because of the speed. I successfully l