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.
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
2. 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’:
Select ‘AutoML Image Classification’ product:
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.
The next step will be to train and evaluate the model.
Lastly, we will test our dataset and model by trying new pictures and letting our app to predict which label we are uploading.
Google’s prediction is that this is a picture of a Green Tea wrapping, and they are absolutely correct!
- Testing your dataset in more difficult circumstances (depending on your use case).
- Integrate Google AutoML with your application as shown in the following diagram:
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.