arrow_back

Using an Image Dataset to Train an AutoML Model

Sign in Join
Get access to 700+ labs and courses

Using an Image Dataset to Train an AutoML Model

Lab 3 hours 30 minutes universal_currency_alt 5 Credits show_chart Advanced
info This lab may incorporate AI tools to support your learning.
Get access to 700+ labs and courses

Overview

In this lab, you create an image classification dataset and import images, train an AutoML image classification model, deploy a model to an endpoint, and send a prediction.

Learning objectives

  • Create an image classification dataset and import images.
  • Train an AutoML image classification model.
  • Deploy a model to an endpoint and send a prediction.

Setup and requirements

For each lab, you get a new Google Cloud project and set of resources for a fixed time at no cost.

  1. Sign in to Qwiklabs using an incognito window.

  2. Note the lab's access time (for example, 1:15:00), and make sure you can finish within that time.
    There is no pause feature. You can restart if needed, but you have to start at the beginning.

  3. When ready, click Start lab.

  4. Note your lab credentials (Username and Password). You will use them to sign in to the Google Cloud Console.

  5. Click Open Google Console.

  6. Click Use another account and copy/paste credentials for this lab into the prompts.
    If you use other credentials, you'll receive errors or incur charges.

  7. Accept the terms and skip the recovery resource page.

Enable the APIs

  1. In the Google Cloud Console, on the Navigation menu, click Vertex AI > Dashboard.
  2. Click Enable all recommended APIs.

Introduction to Vertex AI

This lab uses the newest AI product offering available on Google Cloud. Vertex AI integrates the ML offerings across Google Cloud into a seamless development experience. Previously, models trained with AutoML and custom models were accessible via separate services. The new offering combines both into a single API, along with other new products. You can also migrate existing projects to Vertex AI. If you have any feedback, please see the Get support page.

Vertex AI includes many different products to support end-to-end ML workflows. This lab focuses on the products highlighted below: Training/HP-Tuning and Notebooks.

A diagram displaying the Vertex AI products, with the Training and Notebooks products highlighted.

Task 1. Create an image classification dataset and import images

Image data input file

The image files you use in this tutorial are from the flower dataset used in this Tensorflow blog post. These input images are stored in a public Cloud Storage bucket. This publicly accessible bucket also contains a CSV file you use for data import. This file has two columns: the first column lists an image's URI in Cloud Storage, and the second column contains the image's label. Following are some sample rows.

gs://cloud-training/mlongcp/v3.0_MLonGC/toy_data/flowers_toy.csv:

gs://cloud-samples-data/ai-platform/flowers/daisy/10559679065_50d2b16f6d.jpg,daisy gs://cloud-samples-data/ai-platform/flowers/dandelion/10828951106_c3cd47983f.jpg,dandelion gs://cloud-samples-data/ai-platform/flowers/roses/14312910041_b747240d56_n.jpg,roses gs://cloud-samples-data/ai-platform/flowers/sunflowers/127192624_afa3d9cb84.jpg,sunflowers gs://cloud-samples-data/ai-platform/flowers/tulips/13979098645_50b9eebc02_n.jpg,tulips

Create an image classification dataset and import data

  1. To begin the process of creating your dataset and training your image classification model, on the Vertex AI page, in the navigation pane, click Dashboard.

  2. In the central pane, for Prepare Data, click Create dataset.

  3. Optional: Specify a name for this dataset.

  4. For Select a data type and objective, on the Image tab, select Single-label classification.

  5. For Region, select .

  6. To create the empty dataset, click Create.
    The Import page opens.

  7. Select Select import files from Cloud Storage, and specify the Cloud Storage URI of the CSV file with the image location and label data.

The CSV file is at: gs://cloud-training/mlongcp/v3.0_MLonGC/toy_data/flowers_toy.csv.

  1. For Import file path, type cloud-training/mlongcp/v3.0_MLonGC/toy_data/flowers_toy.csv

  2. To begin image import, click Continue.

    The import process takes about 15 minutes. When it is complete, the next page shows all of the images, both labeled and unlabeled, identified for your dataset.

Task 2. Train an AutoML image classification model

Use the Google Cloud Console to train an AutoML image classification model. After your dataset is created and data is imported, use the Cloud Console to review the training images and begin model training.

Review imported images

After the dataset is imported, the Browse tab opens. You can also access this tab by selecting Datasets from the side menu, and then selecting the annotation set (set of single-label image annotations) associated with your new dataset.

Begin AutoML model training

On the Browse tab, you can choose Train new model to begin training.

  1. On the Vertex AI page, in the navigation pane, click Model Registry.
  2. To open the Train new model page, click Create.
  3. Under Training method, select the target Dataset and Annotation set if they are not automatically selected.
  4. Select AutoML, and then click Continue.
  5. Optional: For Model details, type a Model name.
  6. Click Continue.
  7. Leave the Training options section as default and click Continue.
  8. Under Compute and pricing, for Budget, enter 8 maximum node hours.
  9. Click Start training.

Training takes about 2 hours. When the model finishes training, it is displayed with a green checkmark status icon.

Task 3. Deploy a model to an endpoint and send a prediction

After your AutoML image classification model training is complete, use the Google Cloud Console to create an endpoint and deploy your model to the endpoint. After your model is deployed to this new endpoint, send an image to the model for label prediction.

Deploy your model to an endpoint

Access your trained model to deploy it to a new or existing endpoint from the Models page.

  1. On the Vertex AI page, in the navigation pane, click Model Registry.

  2. Select your trained AutoML model and then click on Version ID.

    The Evaluate tab opens, where you can view model performance metrics.

  3. On the Deploy & Test tab, click Deploy to endpoint.
    The Endpoint options page opens.

  4. Under Define your endpoint, select Create new endpoint, and for Endpoint name, type hello_automl_image.

  5. Click Continue.

  6. Under Model settings, accept the Traffic split of 100%, and set the Number of compute nodes to 1.

  7. Click Deploy.

It takes about 20 minutes to create the endpoint and deploy the AutoML model to the new endpoint.

Send a prediction to your model

After the endpoint creation process finishes, you can send a single image annotation (prediction) request in the Cloud Console.

  • In the Test your model section of the same Deploy & test tab you used to create an endpoint in the previous subtask, click Upload image, choose a local image for prediction, and view its predicted label.

The Test your model page, which includes an image and the Filter labels panel with several filters listed.

End your lab

When you have completed your lab, click End Lab. Qwiklabs removes the resources you’ve used and cleans the account for you.

You will be given an opportunity to rate the lab experience. Select the applicable number of stars, type a comment, and then click Submit.

The number of stars indicates the following:

  • 1 star = Very dissatisfied
  • 2 stars = Dissatisfied
  • 3 stars = Neutral
  • 4 stars = Satisfied
  • 5 stars = Very satisfied

You can close the dialog box if you don't want to provide feedback.

For feedback, suggestions, or corrections, please use the Support tab.

Copyright 2022 Google LLC All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.

Before you begin

  1. Labs create a Google Cloud project and resources for a fixed time
  2. Labs have a time limit and no pause feature. If you end the lab, you'll have to restart from the beginning.
  3. On the top left of your screen, click Start lab to begin

Use private browsing

  1. Copy the provided Username and Password for the lab
  2. Click Open console in private mode

Sign in to the Console

  1. Sign in using your lab credentials. Using other credentials might cause errors or incur charges.
  2. Accept the terms, and skip the recovery resource page
  3. Don't click End lab unless you've finished the lab or want to restart it, as it will clear your work and remove the project

This content is not currently available

We will notify you via email when it becomes available

Great!

We will contact you via email if it becomes available

One lab at a time

Confirm to end all existing labs and start this one

Use private browsing to run the lab

Use an Incognito or private browser window to run this lab. This prevents any conflicts between your personal account and the Student account, which may cause extra charges incurred to your personal account.