Identify images using Tensorflow.

Tram Ho

1. A brief overview of Tensorflow (TF):

Tensorflow (TF) is a library developed by Google and is an open source library used to calculate arithmetic using data flow graph in which nodes are mathematical calculations and edges represent data flow. Whether.

Benefits that this library brings:

  • Integrates many Machine Learning libraries.
  • Has good compatibility and expansion.
  • Recognize pronunciation and translate automatically.
  • Email classification of Gmail.
  • Recognize faces in photos.

TensorFlow is characterized by processing all types of data that can be represented as data flow graphs or low levels such as handwriting processing.

2. Put TF into the Flutter app:

2.1 Add data to TF model:

You can go to to add your data.

Select to create Image Project.

To be able to get the data you download from this page: , then upload to the model above for each type that you set and click Train model for machine to conduct learning.

Then proceed to Export model and Download to device.

Unzip the two files above and proceed to add assets of Flutter project.

2.2 Code UI Detech Animal:

build.gradle to android’s build.gradle add the following 2 lines.

It will disable the compression of files called tflite and lite .

Add the 2 image_picker and tflite libraries to the pupspec.yaml directory

Let’s proceed with the coding. In the main.dart file, write the function to put the models we trained earlier into Tflite.loadModel() to save the model.

Next we add a function to get the image from the phone.

Add the image display and Button get photos from the machine.

2.3 Demo try:

If you select a cat image, it will say 0 Cat .

If you select a dog image, you will notice it is 1 Dog .


I have instructed you to make a simple Detect animal app using Tensorflow, but there are still some disadvantages such as: If you choose an image that is not a dog or a cat, you may get a wrong result because of the lack of Data Training.

Hope you enjoyed this article.

Link source code.

Share the news now

Source : Viblo