Android TensorFlow Lite Machine Learning Example

Amit Shekhar
MindOrks
Published in
2 min readMar 17, 2018
TensorFlow Lite Machine Learning Example

I am Amit Shekhar, Co-Founder @ Outcome School • IIT 2010–14 • I have taught and mentored many developers, and their efforts landed them high-paying tech jobs, helped many tech companies in solving their unique problems, and created many open-source libraries being used by top companies. I am passionate about sharing knowledge through open-source, blogs, and videos.

This blog is about the Android TensorFlow Lite Machine Learning Example.

Using TensorFlow Lite Library For Object Detection

TensorFlow Lite is TensorFlow’s lightweight solution for mobile devices.

TensorFlow Lite is better as:

  • TensorFlow Lite enables on-device machine learning inference with low latency. Hence, it is fast.
  • TensorFlow Lite takes a small binary size. Hence, good for mobile devices.
  • TensorFlow Lite also supports hardware acceleration with the Android Neural Networks API.

TensorFlow Lite uses many techniques for achieving low latency such as:

  • Optimizing the kernels for mobile apps.
  • Pre-fused activations.
  • Quantized kernels that allow smaller and faster (fixed-point math) models.

How to use TensorFlow Lite in an Android application?

The most important tricky part while using the TensorFlow Lite is to prepare the model(.tflite) which is different from the normal TensorFlow model.

In order to run the model with the TensorFlow Lite, you will have to convert the model into the model(.tflite) which is accepted by the TensorFlow Lite. Follow the steps from here.

Now, you will have the model(.tflite) and the label file. You can start using these model and label files in your Android application to load the model and to predict the output using the TensorFlow Lite library.

I have created a complete running sample application using the TensorFlow Lite for object detection. Check out the project here.

Credit: The classifier example has been taken from the Google TensorFlow example.

Sample Application — Object Detection Example

Object Detection
Object Detection

Complete Project Link.

Happy Learning AI :)

Prepare yourself for Android Interview: Android Interview Questions

You can find the Roadmap for Android Developer here: Android Developer Roadmap

Thanks

Amit Shekhar

Co-Founder @ Outcome School

Also, Let’s become friends on Twitter, Linkedin, Github, and Facebook.

--

--

Amit Shekhar
MindOrks

Co-Founder @ Outcome School | Coder | Teacher | Mentor | Open Source | IIT 2010-14 | Android | Machine Learning | Backend