How to train machine learning models, to classify images according to the labels you define.

In this tutorial, we will use AutoML Vision to solve an image classification problem. We will train the model to classify the flavor of tea by using an image of its wrapping.


Pre-requisites:

An active subscription to Google Cloud Platform.

  • Four or more objects you want to classify.

Creating the Dataset

1. Create one video per object (between 5 to 10 seconds).

Consider there are many aspects to consider in an ideal scenario. Some of them are:

  • Different angles.
  • Multiple light levels.
  • Object state
  1. We’ll use https://ffmpeg.org/, to get multiple frames from the video. AutoML requires at least 100 images per object to train the model.

Of course, the more the better :)

3. Save the frames in different folders. One folder per label.

You can check the official beginner's guide here.


Google Cloud Platform

Go to Google Cloud Platform Home, search for ‘Vision’:

Image classification google cloud platform step by step

Select ‘AutoML Image Classification’ product:

Auto ML Image classification process step by step

Specify the Google Cloud project name and start by creating a New Dataset.

Give the model a name and then click on the Import images later option. This will let us import each of the images from a folder linked to a label we’ll create soon.

In the next step, click on New Label and add one label per object you want to classify. In my case, it will be four different flavors: Black, Green, Lemon, and Indian.

Select every newly created label and click on Add Images button at the top. Choose the Upload from your computer option. Select all the images from the folder linked to that label.

We should have more than 100 images linked to each of the labels created.

Image classification Auto ML how to step by step

The next step will be to train and evaluate the model.

AutoML vision step by step guide

Lastly, we will test our dataset and model by trying new pictures and letting our app to predict which label we are uploading.

AutoML step by step guida testing

Google’s prediction is that this is a picture of a Green Tea wrapping, and they are absolutely correct!


Next steps:

  • Testing your dataset in more difficult circumstances (depending on your use case).
  • Integrate Google AutoML with your application as shown in the following diagram:
How AutoMLWorks explanation

Conclusion:

It's an excellent time to get involved with emerging technologies such as ML and Computer vision.

Don’t forget you don’t need to re-invent the wheel, you simply need to know how to best use the tools available to you.

Make sure to ask any questions in the comments below.