arrow_back

Classifying Images of Clouds in the Cloud with AutoML Vision

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

Classifying Images of Clouds in the Cloud with AutoML Vision

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

Overview

In this lab, you upload images to Cloud Storage and use them to train a custom model to recognize different types of clouds (cumulus, cumulonimbus, etc.).

What you learn

In this lab, you learn how to perform the following tasks:

  • Upload a labeled dataset to Cloud Storage and connect it to AutoML Vision with a CSV label file
  • Train a model with AutoML Vision and evaluate its accuracy
  • Generate predictions on your trained model

Set up your environments

Lab setup

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.

Task 1. Set up AutoML Vision

AutoML Vision provides an interface for all the steps in training an image classification model and generating predictions on it. Start by enabling the AutoML API.

Open the navigation menu and and select APIs & Services > Library. In the search bar type in "Cloud AutoML API". Click on the Cloud AutoML API result and then click Enable.

This may take a minute. You should now be on the following page (ensure that the Activation Status is Enabled):

Cloud AutoML API result

Similarly, in the search bar type in "Vertex AI API". Click on the Vertex AI API result and then click Enable.

Create a Cloud Storage bucket for your training data

  1. On the GCP Console title bar, click Activate Cloud Shell (Cloud_shell icon).
  2. When prompted, click Continue.

In Cloud Shell, paste the below command to make a new bucket to hold your training. We use the magic variable $DEVSHELL_PROJECT_ID, which knows your current project, and simply add -vcm to the end.

  1. Run the below command in Cloud Shell:
gsutil mb -p $DEVSHELL_PROJECT_ID \ -c regional \ -l us-central1 \ gs://$DEVSHELL_PROJECT_ID-vcm/

Leave your Cloud Shell window open for additional steps to follow.

  1. Click to open the AutoML UI in a new browser tab.

The AutoML Vision datasets page opens once the APIs are verified.

Task 2. Upload training images to Cloud Storage

In order to train a model to classify images of clouds, you need to provide labeled training data so the model can develop an understanding of the image features associated with different types of clouds. In this example, your model will learn to classify three different types of clouds: cirrus, cumulus, and cumulonimbus. To use AutoML Vision you need to put your training images in Cloud Storage.

  1. In the Cloud Console, open the Navigation menu and select Cloud Storage > Browser.

Once there, you should see the bucket from the last step.

  1. The training images are publicly available in a Cloud Storage bucket. To copy the images from Cloud Storage and extract the contents from the archive, run the following command:
gcloud storage cp gs://cloud-training/automl-lab-clouds/automl-lab-clouds.zip . && unzip automl-lab-clouds && rm automl-lab-clouds.zip
  1. Use the gcloud storage command-line utility for Cloud Storage to copy the training images into your bucket:
gcloud storage cp -r automl-lab-clouds/* gs://$DEVSHELL_PROJECT_ID-vcm/
  1. Once copying is complete you can view the CSV file and three types of clouds you have images for:
gsutil ls gs://$DEVSHELL_PROJECT_ID-vcm/

Optional: View the images using the Cloud Storage Console UI

  1. When the images finish copying, click the Refresh button at the top of the Cloud Storage browser.
  2. Then click on your bucket name. You should see a data.csv file and 3 folders of photos for each of the 3 different cloud types to be classified:

If you click on the individual image files in each folder, and then click once more when you see the URL, you can see the photos you'll be using to train your model for each type of cloud.

Task 3. Create an AutoML Vision training dataset

Now that your training data is in Cloud Storage, you need a way for AutoML Vision to access it. You'll create a CSV file where each row contains a URL to a training image and the associated label for that image. This CSV file has been created for you; you just need to update it with your bucket name.

  1. Run the following commands which:
  • Copy the template file to your Cloud Shell instance
  • Update the CSV with the files in your project
  • Upload this updated CSV file to your Cloud Storage bucket
  • Show the bucket to confirm the data.csv file is present
gsutil cp gs://cloud-training/automl-lab-clouds/data.csv . head --lines=10 data.csv sed -i -e "s/placeholder/$DEVSHELL_PROJECT_ID-vcm/g" ./data.csv head --lines=10 data.csv gsutil cp ./data.csv gs://$DEVSHELL_PROJECT_ID-vcm/ gsutil ls gs://$DEVSHELL_PROJECT_ID-vcm/
  1. View all the folders and files in your bucket you can add a wildcard to gsutil ls like so:
gsutil ls gs://$DEVSHELL_PROJECT_ID-vcm/*
  1. Highlight and copy the location of your data file to your clipboard which will look similar to: gs://qwiklabs-gcp-your-project-id-will-be-here-vcm/data.csv

  2. Click to open the AutoML Vision datasets page.

  3. At the top of the Cloud Console, click Create dataset.

  4. Type clouds for the dataset name.

  5. Select Single-label classification.

  6. Click Create to continue.

Create new dataset page

On the next screen you will choose the location of your training images (the ones you uploaded in the previous step).

  1. Choose Select import files from Cloud Storage and add the file name to the URL for the file that is in your clipboard from the previous step. You may also use the browse function to find the csv file. Once you see the white in green checkbox you may select Continue to proceed.

Select a CSV file on Cloud Storage section

  1. Once the import has completed click the Browse tab to see the images in your dataset.
  • It will take 8 to 12 minutes while the image metadata is processed ("Running: Importing Images" will appear on the screen).
  • Once complete, the images will appear by category.

Task 4. Inspect the images

  1. Next, proceed with a brief examination of the images.

Images of clouds

  1. Try filtering by different labels in the left menu (i.e. click cumulus) to review the training images.

Filter menu

Note: If you were building a production model, you'd want at least 100 images per label to ensure high accuracy. This is just a demo so only 20 images of each type were used so the model could train quickly.
  1. If any images are labeled incorrectly you can click on them to switch the label or delete the image from your training set:

Image details

Note: If you are working with a dataset that isn't already labeled, AutoML Vision provides an in-house human labeling service.

Task 5. Train your model

You're ready to start training your model! AutoML Vision handles this for you automatically, without requiring you to write any of the model code.

  1. To train your clouds model, click Train New Model from the right-side pane.

  2. From the Training method window, select AutoML as the training method and leave Cloud selected for Choose where to use the model.

  3. Click Continue.

  4. Enter a name for your model, or use the default auto-generated name and click Continue.

  5. For the Training options window, click Continue.

  6. From Compute and pricing window, set your budget to 8 maximum node hours.

  7. Click Start Training.

Note: Training this custom model can be expected to take over an hour to complete (55 to 90 minutes on average). The total training time includes node training time as well as infrastructure setup and tear down. To get full credit for the lab you do not need to wait for training to complete and can simply review the below screenshots from Evaluation and Prediction.

Task 6. Evaluate your model

  1. After training is complete, select the Evaluate tab. Here you'll see information about Precision and Recall of the model. It should resemble the following:

Evaluate tabbed page

  1. You can also adjust the Confidence threshold slider to see its impact.

  2. Finally, scroll down to take a look at the Confusion matrix.

confusion matrix

This tab provides some common machine learning metrics to evaluate your model accuracy and see where you can improve your training data. Since the focus for this lab was not on accuracy, move on to the next section about predictions. Feel free to browse the accuracy metrics on your own.

Task 7. Deploy to endpoint

  1. From the Vertex AI navigation menu on the left, select Models Registry.

  2. Click the model you just created (damaged-car-part-model) and then click on Version ID.

  3. Click on DEPLOY & TEST tab, click Deploy to Endpoint.

  4. For the name, use damaged-car-part-model-endpoint. Click Continue.

  5. Keep the Traffic Split and Logging as default and set the Number of compute nodes to 1.

  6. Click Done. Then click Deploy.

Task 8. Generate predictions

Now it's time for the most important part: generating predictions on your trained model using data it hasn't seen before.

There are a few ways to generate predictions. In this lab you use the UI to upload images. You'll see how your model does classifying these two images (the first is a cirrus cloud, the second is a cumulonimbus).

  1. First, download these images to your local machine by right-clicking on each of them (Note: You may want to assign a simple name like 'Image1' and 'Image2' to assist with uploading later):

Cirrus cloud

Cumulonimbus cloud

  1. Navigate to the Deploy & test tab in the AutoML UI.\

  2. Under your newly deployed endpoint, click the Upload Image button under Test your model.

  3. Follow the prompts to select and upload the sample images you just saved to your local disk. When the prediction requests complete you should see something like the following:

clouds Test and Use tabbed page

When the prediction request completes you should see something like the following:

Predictions: 1 object: cirrus

Predictions: 1 object: cumulonimbus

Excellent - the model classified each type of cloud correctly!

Congratulations!

You've learned how to train your own custom machine learning model and generate predictions on it through the web UI. Now you've got what it takes to train a model on your own image dataset.

What was covered

  • Uploading training images to Cloud Storage and creating a CSV for AutoML Vision to find these images.
  • Reviewing labels and training a model in the AutoML Vision UI.
  • Generating predictions on new cloud images.

End your lab

When you have completed your lab, click End Lab. Google Cloud Skills Boost 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 2025 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. 除非您已完成此实验或想要重新开始,否则请勿点击结束实验,因为点击后系统会清除您的工作并移除该项目

此内容目前不可用

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

太好了!

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

一次一个实验

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

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

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