Fruits Prediction Android App using TensorFlow Lite| Android-Machine Learning

In this tutorial, we can create a Fruits Prediction app using TensorFlow Lite. Before going to create the app first understand what TensorFlow is.

What is TensorFlow?

TensorFlow makes it easy for beginners and experts to create machine learning models for desktop, mobile, web, and cloud. Platforms, where you can use TensorFlow are Python, Swift, JavaScript, Android, iOS, and End to End production.

What is TensorFlow Lite?

Now let’s see how to create a Fruits Prediction app using TensorFlow Lite.

Get Started

1. Collect the Database

2. Train the model

3. Export the model

4. Add into Android

  • Now get the Android app example Github.
  • Now unpack the Quantized tflite model (converted_tflite_quantized.zip) and Floating-Point tflite model (converted_tflite.zip) archive exported from Teachable Machine.
  • In the quantized tflite model, you will find two files labels.txt and model.tflite. Also in the unquantized tflite model, you will find two files labels.txt and model_unquant.tflite. Both labels.txt files are the same. So you can keep only one label file. In the labels.txt file, you have all the list of classes of fruits.
  • Next, Copy the labels.txt, model_unquant.tflite and model.tflite files to the example asset folder.

examples/lite/examples/image_classification/android/app/src/main/assets/

  • Open

examples/lite/examples/image_classification/android/

  • Modify getModelPath() and getLabelPath() to

@Override

Protected String getModelPath() {

Return “model.tflite”;

}

@Override

Protected String getLabelPath() {

Return “labels.txt”;

}

  • Now run the app.

Output

If you need the full source code or any session please mail me at barmangolap15@gmail.com

and visit www.gbandroidblogs.com

Happy Coding!!

Hi everyone, myself Golap an Android app developer with UI/UX designer.