Features
June 28, 2022

Search by image feature with Flutter & TensorFlow

The easy way to implement search by image is using TensorFlow.

What is TensorFlow?


The TensorFlow platform helps you implement best practices for data automation, model tracking, performance monitoring, and model retraining. Using production-level tools to automate and track model training over the lifetime of a product, service, or business process is critical to success.

We used TensorFlow lite to get a label from the image. For example, if you have an image containing a car, then TensorFlow can let you know that image contain a car. TensorFlow has machine learning to recognize objects from your image, so we can use the label image from TensorFlow as a keyword to search data.

How it work?

Visual Search applications are those applications that provide information in a visual form like an image, video, etc. such applications can be categorized into two main groups, one is to display an image or video as a result of any query based on keywords, and the other is to recognize visual content such as an image or a video and search for it.

To implement the search by image feature, at least we have 5 steps.

  1. Pick an image from the user's device
  2. Cropping an image to specify the target object
  3. Get a label from the image using TensorFlow
  4. We use the label keyword to query data from the backend
  5. Show data
Search by Image workflow with TensorFlow

I want to show you how to implement search by image feature using TensorFlow from scratch. You can get this sample project on my GitHub or follow it step by step on video.

Dependencies

We need to use some packages to make it easy and speed up the development process.

  • http: We use this package to request API.
  • get: We use this for state management, routing, and utility.
  • image_cropper: We use this package to crop images.
  • image_picker: We use this package to pick images from device.
  • tflite: We use this package to access TensorFlow Lite.

Result

We have created a search by image feature. You can check the code result on GitHub. If you have any issues, please let me know and send me an email, or you can create new issues on the GitHub repository.

Get On GitHub

This sample project is just for my portfolio. You can use this sample project for your personal and client projects (paid or unpaid projects). This is a free open-source project, so please do not sell this project on Codecanyon, etc.
Sometimes the app can't recognize objects in your image. You have to add more models so machine learning can recognize more objects. If you need some help, you can hire me to continue your project.