arrow_back

Using an Image Dataset to Train an AutoML Model

登录 加入
访问 700 多个实验和课程

Using an Image Dataset to Train an AutoML Model

实验 3 个小时 30 分钟 universal_currency_alt 5 积分 show_chart 高级
info 此实验可能会提供 AI 工具来支持您学习。
访问 700 多个实验和课程

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.

准备工作

  1. 实验会创建一个 Google Cloud 项目和一些资源,供您使用限定的一段时间
  2. 实验有时间限制,并且没有暂停功能。如果您中途结束实验,则必须重新开始。
  3. 在屏幕左上角,点击开始实验即可开始

使用无痕浏览模式

  1. 复制系统为实验提供的用户名密码
  2. 在无痕浏览模式下,点击打开控制台

登录控制台

  1. 使用您的实验凭证登录。使用其他凭证可能会导致错误或产生费用。
  2. 接受条款,并跳过恢复资源页面
  3. 除非您已完成此实验或想要重新开始,否则请勿点击结束实验,因为点击后系统会清除您的工作并移除该项目

此内容目前不可用

一旦可用,我们会通过电子邮件告知您

太好了!

一旦可用,我们会通过电子邮件告知您

一次一个实验

确认结束所有现有实验并开始此实验

使用无痕浏览模式运行实验

请使用无痕模式或无痕式浏览器窗口运行此实验。这可以避免您的个人账号与学生账号之间发生冲突,这种冲突可能导致您的个人账号产生额外费用。