veesamkrao / Custom-Object-Detection-on-Android-using-TF-Lite

An end-to-end tutorial to train a custom object detection model and deploy it on Android using TensorFlow Lite.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Custom-Object-Detection-on-Android-using-TF-Lite

An end-to-end tutorial to train a custom object detection model and deploy it on Android using TensorFlow Lite.

Steps:

  1. Prepare your dataset and label them in PascalVOC format using LabelImg.

  2. Programmatically convert all the raw images in your dataset in the JPEG format using this script. Doing so will ensure that you don't face any error while loading your dataset during model training.

  3. Once you've converted the raw images, partition the dataset into train and test data in the following directory structure.

<your_dataset_name.zip>
|__ train
|    |__ images (all training image files - *.jpg)
|    |__ annotations (all training annotation files - *.xml)
|__ test
     |__ images (all test image files - *.jpg)
     |__ annotations (all test annotation files - *.xml) 

Once done, upload your zipped dataset on Kaggle/Google Drive.

  1. Clone the repository on your local machine.

  2. Sign in to your Google account and upload the Custom_Object_Detection_using_TF_Lite_Model_Maker.ipynb notebook on Colab.

  3. Run the notebook cells one-by-one by following the instructions.

  4. Once the TF Lite model is downloaded, copy the model.tflite model file inside Custom-Object-Detection-on-Android-using-TF-Lite/Android_App/app/src/main/assets directory.

  5. Open the project in Android Studio and let it build itself for some time.

  6. Open MainActivity.kt file and edit Line 130 by replacing <your_model.tflite> with the name of your actual TF Lite model.

  7. Build the project and install it on your phone. Enjoy your own custom-built object detector app.

Output:

GitHub Logo

About

An end-to-end tutorial to train a custom object detection model and deploy it on Android using TensorFlow Lite.


Languages

Language:Kotlin 49.4%Language:Jupyter Notebook 47.4%Language:Java 1.7%Language:Python 1.5%