DEV Community

Cover image for Custom Object Detection Using TensorFlow Teachable Machine In Flutter Apps
Shivam Ahuja
Shivam Ahuja

Posted on

Custom Object Detection Using TensorFlow Teachable Machine In Flutter Apps

There are plenty of articles available on Training your own custom object detection model using TensorFlow, YoloV3, Keras, etc. But most of us doesn't know how to do it or want to spend a lot of time on just reading and understanding the algorithms and then creating our own dataset and then training that dataset which requires resources and time and a lot of research, So if you are one of us this article is for you

Here is a sneak peek of what's about to happen:-

1. Collect images for training.
2. Upload dataset to TensorFlow Teachable Machine to train the model.
3. Export the model with .tflite extension to be used in your app.
4. Clone the repository and install the dependencies.
5. Replace the .tflite file and .txt file in the assets/tflite folder with your custom model .tflite file and make sure to rename it.
6. Run the app and congratulations🎊🎉 , there you have your custom object detector up and running.

Let's begin.

Step 1: Collecting Images

Alt Text
It’s very difficult to manually download each and every image from the internet. NO worries today I’m here to make your life easier.
Here is a Chrome extension to download images in bulk in one go Imageye. Just add it to your browser, search for the object you are looking for. Click on the extension and BOOM!! there you go all the images will be downloaded.

Step 2: Uploading the dataset for training

Alt Text
Open this link. just like show in the picture you have to create a class give the class a label, click on upload>choose images from your files>select the images that you have previously downloaded, repeat this step for all the objects that you want to detect.
Now you are ready to train your model by just clicking on the Train Model button.

Step 3: Exporting the trained model

Alt Text
After the model is trained you can test it by uploading an image and the result will be displayed below.
If everything is working well, now you can export the model. Click on the Export Model button and this popup will open, now select the TensoflowLite tab and click on Download my model. It will download a zip file for you.

Step 4: Creating the flutter project

Clone this repository and install the dependencies by running the command in the terminal

Flutter pub get

Step 5: Replacing the custom trained model with your model

In the assets/tflite folder, you will find two files i.e. ssd_mobilenet.tflite and ssd_mobilenet.txt. Extract the zip file that you downloaded above and replace these files in the assets folder and make sure to rename them.

Step 6: Run the app and test it

Alt Text
Now simply you just have to run the app and the interface looks like this, obviously, this is a demo UI you can make your own tweaks and changes to make it shine.
There You Goo, CONGRATULATIONS 🎊🎉 on your own custom object detector

If you have made it through this article very well make sure to start this repository if you like it, have a good day.
Thanks for reading. ✌️
for any queries connect with me on LinkedIn

Top comments (1)

Collapse
 
brha8286 profile image
brha8286

This is really image classification. Any chance you (or anyone) knows if Teachable Machine can be used for object detection?