Custom Image Classification(Fruits Classification) in Android device trained in teachablemachine with google.
Custom Image Classification to continuously classify whatever it sees from the android device's back camera. Inference is performed using the TensorFlow Lite Java API. The demo app classifies frames in real-time, displaying the top most probable classifications. It allows the user to choose between a floating point or quantized model optimization.
These instructions walk you through training,building and running the demo on an Android device.
The training platform used for training custom image classifier is the teachablemachine with google. This is an exciting platform for learning the deeplearning training process just at a click by just uploading the different class of dataset or using webcam, then train it quite easily. Finally, after training you can export the model of your choice. I have exported it to tensorflowlite version as I have to run this on android device. you can choose whatever format you want and download the model.
-
Image dataset of different classes(for custom training) (you can download the fruit dataset collected:) Fruit
-
Android Studio 3.2 (installed on a Linux, Mac or Windows machine)
-
Android device in developer mode with USB debugging enabled
-
USB cable (to connect Android device to your computer)
Prepare and upload the dataset to the teachablemachine with google site and define the number of classes accordingly. Train the image classification model over there and finally, export the model in the form of tensorflowlite format.
Clone this GitHub repository to your computer and save it to the folder of your choice. This the java code for android application.
Select Build -> Make Project
and check that the project builds successfully.
You will need Android SDK configured in the settings. You'll need at least SDK
version 23. The build.gradle
file will prompt you to download any missing
libraries.
you have to put the fruits.tflite to the asset folder of the android structure
project directory and change the labels according to the number of class you have trained.
Connect the Android device to the computer and be sure to approve any ADB
permission prompts that appear on your phone. Select Run -> Run app.
Select
the deployment target in the connected devices to the device on which the app
will be installed. This will install the app on the device.