Creating a simple Image Classification Android App
Don’t know how to code an android app and how to develop a high end Tensorflow model? Don’t worry we have you sorted Just follow up the steps below. The Android app development makes use of 2 major developer tools:
1. Tensorflow lite
2. Android Studio
Below is the detailed description of how anyone can develop this app. Steps to develop the image classification app :
Step 1 is preparing the dataset , select atleast 20 images of as many classes of object you want to classify then put then in different folders and your customised dataset is prepared.
Step 2 is to go to the machine learning techables link (https://teachablemachine.withgoogle.com) this is sponsered by google and provides a simple GUI way to create our ML models without the need to writting the code next select image project and add your dataset folders as different classes into it .
Step 3 is to train the machine and wait for it to show the preview of the model. then select export model and of the 3 options provided select Tensorflow Lite and select Floating point and Quantized and download the model.
Step 4 Now to get the Android code from Github click on this link (https://github.com/tensorflow/examples/tree/master/lite/examples/image_classification/android)And clone the app style you want.
Step 6 align the lables in the lables.txt file in the following format :
Step 7 open the app code in android studio and on the 101th line of CameraActivity file change return value to MODEL.FLOAT_EFFICIENT.
In CLASSIFIER FLOAT MOBILENET file on line 55 change the return value to ‘model_unquant.tflite’
In CLASSIFIER.FLOAT_EFFICIENT file line 53 return value to ‘model_unquant.tflite’ and return lables.txt on line 57.
In files ClassifierQuantizedMobileNet and ClassifierQuantizedEfficientNet change the return values to ‘model.tflite’ and 2md return to ‘labels.txt’
This completes our task now either use a simulator or you own phone to run the app and try it with different images and test the accuracy of your model. Here is the screen-shorts of my results.
This is a basic version of my app developed as a part of my Open Source Contribution Journey more changes and up-gradation is in progress. You can refer to this code as a part of my contribution on the Project link :