Original article was published on Artificial Intelligence on Medium
Google’s AutoML lets you train custom machine learning models without having to code
Training high-performance deep networks is often a big task especially for those who have less experience in deep learning or AI. Also, we might require GPU in addition to RAM and CPU. I experienced a lot of issues while trying to classify with CNN.
What if I said Google AutoML Vision will solve our problems? Yes, AutoML Vision enables us to train custom machine learning models to classify our images according to our own defined labels. It will train the model from labeled images and evaluate the performance. It doesn’t require the user to have any knowledge of deep learning or AI, all you need is labeled data! It will Train, Deploy, and Server the application for us.
In this article, I am going to show you how to use Google AutoML for facial expression recognition.
Are you excited? Let’s dive deep before it’s too late!
Preparing the Labeled DataSet
The data in facial expressions come from a variety of sources which includes
I downloaded a CSV file, a dataset that consists of pixels of both the training and testing images provided by Kaggle.
Now we have the data frame with pixels of an image and its corresponding label (0=Angry, 1=Disgust, 2=Fear, 3=Happy, 4=Sad, 5=Surprise, 6=Neutral). We need to get the images from those pixel values and organize each label in a separate folder.
After the images are organized you can count the number of images present in each label. Make sure the dataset is balanced with each label having a similar number of images (at least the count should not vary drastically) for better results.
After the images are organized perfectly, your dataset folder would look something like this,
Before you can use the Cloud Vision API, you must enable it for your project:
Google offers you 300$ credits for new customers in order to get started on Google Cloud Platform for free. If you are not using free tier, Google charges you for every resource you create.
- Sign in to your Google Account.
- In the Cloud Console, on the project selector page, select or create a Cloud project.
- Make sure that billing is enabled for your Google Cloud project.
- Enable the Cloud Vision API.
- Set up authentication.
For additional information click here.
Create New DataSet
After the initial setup, you can see the Vision Dashboard as shown above. Now click on Get Started.
You will be redirected to a console to create a new dataset. Give it a name, select your model objective, and click on CREATE DATASET.
Now upload the dataset zip file by clicking on SELECT FILES. And browse the destination on cloud storage i.e, the path for a bucket to store the dataset. Click on CONTINUE. We can also import a CSV file with links to images.
It will take some time to import the dataset.
Once the dataset is imported, you can check the number of images in each label. We can add new labels here, delete any images. You can see the total number of images is 38,535. But out initial dataset contains 41,944 samples, it is because some images will be discarded by AutoML by default (with Error: The label is already a ground truth).
Click on LABEL STATS, to check the number of images used for training, validation, and testing.
Train the Model
Now we have the labeled dataset imported to google cloud. We can train the model by selecting START TRAINING.
Now a console will appear to train the model,
Give the model a name and select Edge to download the model file for later use. Also, you can select Cloud-hosted if you want to host the model on Google cloud. Click on CONTINUE.
After Defining the model, we need to optimize it by trading off between the package size(model file), Response time, accuracy. Choose an option required for your application and click on CONTINUE.
In the Final Step, we need to set the budget. AutoML will recommend the number of nodes necessary to train the model. However, you can decrease or increase the node hours. (NOTE: more the node hours cost will be high). Click on START TRAINING. Training may take several hours and you will get an email once training is finished.
Click on the link to start using your model.
Evaluate the Model
Once the training is finished, we can check the details of the model i.e, the number of samples (images) used for training, time took for training, Precision, Recall, etc. Click on SEE FULL EVALUATION.
Avergare Precision is 76%