Custom Object Detection Using TensorFlow Teachable Machine In Flutter Apps
Published: 2020-11-12 10:47:54

**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](https://dev-to-uploads.s3.amazonaws.com/i/g8086d8bks271q6o0tvc.PNG)
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*](https://chrome.google.com/webstore/detail/imageye-image-downloader/agionbommeaifngbhincahgmoflcikhm?hl=en). 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](https://dev-to-uploads.s3.amazonaws.com/i/00bq0d7bdk0atb5h7gxf.PNG)
Open this [*link*](https://teachablemachine.withgoogle.com/train/image). 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](https://dev-to-uploads.s3.amazonaws.com/i/or3ebnpn6l756mtolvh3.PNG)
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](https://github.com/skullcandy69/ObjectDetection) 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](https://dev-to-uploads.s3.amazonaws.com/i/dpasq98weamyypsearie.jpg)
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](https://github.com/skullcandy69/ObjectDetection) repository if you like it, have a good day.
Thanks for reading. ✌️
for any queries connect with me on [LinkedIn](https://www.linkedin.com/in/shivam-ahuja-680681150/)