Identify Damaged Car Parts with Vertex AutoML Vision

Join Sign in

Identify Damaged Car Parts with Vertex AutoML Vision

1 hour 30 minutes 5 Credits


Google Cloud self-paced labs logo


Vertex AI brings together the Google Cloud services for building ML under one, unified UI and API. In Vertex AI, you can now easily train and compare models using AutoML or custom code training and all your models are stored in one central model repository. These models can now be deployed to the same endpoints on Vertex AI.

AutoML Vision helps anyone with limited Machine Learning (ML) expertise train high quality image classification models. In this hands-on lab, you will learn how to produce a custom ML model that automatically recognizes damaged car parts.

Once you’ve produced your ML model, it’ll be immediately available for use. You can use the UI or the REST API to start generating predictions directly from the Google Cloud Console.


In this lab, you learn how to:

  • Upload a labeled dataset to Cloud Storage using a CSV file and connect it to Vertex AI as a Managed Dataset

  • Inspect uploaded images to ensure there are no errors in your dataset

  • Review your trained model and evaluate its accuracy

Setup and requirements

Before you click the Start Lab button

Read these instructions. Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources will be made available to you.

This hands-on lab lets you do the lab activities yourself in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials that you use to sign in and access Google Cloud for the duration of the lab.

To complete this lab, you need:

  • Access to a standard internet browser (Chrome browser recommended).
Note: 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.
  • Time to complete the lab---remember, once you start, you cannot pause a lab.
Note: If you already have your own personal Google Cloud account or project, do not use it for this lab to avoid extra charges to your account.

How to start your lab and sign in to the Google Cloud Console

  1. Click the Start Lab button. If you need to pay for the lab, a pop-up opens for you to select your payment method. On the left is the Lab Details panel with the following:

    • The Open Google Console button
    • Time remaining
    • The temporary credentials that you must use for this lab
    • Other information, if needed, to step through this lab
  2. Click Open Google Console. The lab spins up resources, and then opens another tab that shows the Sign in page.

    Tip: Arrange the tabs in separate windows, side-by-side.

    Note: If you see the Choose an account dialog, click Use Another Account.
  3. If necessary, copy the Username from the Lab Details panel and paste it into the Sign in dialog. Click Next.

  4. Copy the Password from the Lab Details panel and paste it into the Welcome dialog. Click Next.

    Important: You must use the credentials from the left panel. Do not use your Google Cloud Skills Boost credentials. Note: Using your own Google Cloud account for this lab may incur extra charges.
  5. Click through the subsequent pages:

    • Accept the terms and conditions.
    • Do not add recovery options or two-factor authentication (because this is a temporary account).
    • Do not sign up for free trials.

After a few moments, the Cloud Console opens in this tab.

Note: You can view the menu with a list of Google Cloud Products and Services by clicking the Navigation menu at the top-left. Navigation menu icon

Activate Cloud Shell

Cloud Shell is a virtual machine that is loaded with development tools. It offers a persistent 5GB home directory and runs on the Google Cloud. Cloud Shell provides command-line access to your Google Cloud resources.

  1. Click Activate Cloud Shell Activate Cloud Shell icon at the top of the Google Cloud console.

  2. Click Continue.

It takes a few moments to provision and connect to the environment. When you are connected, you are already authenticated, and the project is set to your PROJECT_ID. The output contains a line that declares the PROJECT_ID for this session:

Your Cloud Platform project in this session is set to YOUR_PROJECT_ID

gcloud is the command-line tool for Google Cloud. It comes pre-installed on Cloud Shell and supports tab-completion.

  1. (Optional) You can list the active account name with this command:

gcloud auth list


ACTIVE: * ACCOUNT: To set the active account, run: $ gcloud config set account `ACCOUNT`
  1. (Optional) You can list the project ID with this command:

gcloud config list project


[core] project = <project_ID>

Example output:

[core] project = qwiklabs-gcp-44776a13dea667a6 Note: For full documentation of gcloud, in Google Cloud, refer to the gcloud CLI overview guide.

Task 1. Upload training images to Cloud Storage

In this task you will upload the training images you want to use to Cloud Storage. This will make it easier to import the data into Vertex AI later.

To train a model to classify images of damaged car parts, you need to provide the machine with labeled training data. The model will use the data to develop an understanding of each image, differentiating between car parts and those with damages on them.

Note: For the purposes of this lab, you won’t need to label images because a labeled dataset (i.e. image plus label) in a CSV file has been provided. The next section outlines the steps to use the CSV file.

In this example, your model will learn to classify five different damaged car parts: bumper, engine compartment, hood, lateral, and windshield.

Create a Cloud Storage bucket

  1. To start, open a new Cloud Shell window and execute the following commands to set some environment variables:

  1. Next, to create a Cloud Storage bucket, execute the following command:
gsutil mb -p $PROJECT_ID \ -c standard \ -l us-central1 \ gs://${BUCKET}

Upload car images to your Storage Bucket

The training images are publicly available in a Cloud Storage bucket. Again, copy and paste the script template below into Cloud Shell to copy the images into your own bucket.

  1. To copy images into your Cloud Storage bucket, execute the following command:

gsutil -m cp -r gs://car_damage_lab_images/* gs://${BUCKET}
  1. In the navigation pane, click Cloud Storage > Browser.

  2. Click the Refresh button at the top of the Cloud Storage browser.

  3. Click on your bucket name. You should see five folders of photos for each of the five different damaged car parts to be classified:

Bucket with folders titled: bumper, engine compartment, hood, lateral, and windshield.

  1. Optionally, you can click one of the folders and check out the images inside.

Great! Your car images are now organized and ready for training.

Click Check my progress to verify the objective. Upload car images to your Storage Bucket

Task 2. Create a dataset

In this task, you create a new dataset and connect your dataset to your training images to allow Vertex AI to access them.

Normally, you would create a CSV file where each row contains a URL to a training image and the associated label for that image. In this case, the CSV file has been created for you; you just need to update it with your bucket name and upload the CSV file to your Cloud Storage bucket.

Update the CSV file

Copy and paste the script templates below into Cloud Shell and press enter to update, and upload the CSV file.

  1. To create a copy of the file, execute the following command:
gsutil cp gs://car_damage_lab_metadata/data.csv .
  1. To update the CSV with the path to your storage, execute the following command:
sed -i -e "s/car_damage_lab_images/${BUCKET}/g" ./data.csv
  1. Verify your bucket name was inserted into the CSV properly:

cat ./data.csv
  1. To upload the CSV file to your Cloud Storage bucket, execute the following command:
gsutil cp ./data.csv gs://${BUCKET}
  1. Once the command completes, click the Refresh button at the top of the Cloud Storage browser and open your bucket.

  2. Confirm that the data.csv file is listed in your bucket.

data-csv file

Create a managed dataset

  1. In the Google Cloud Console, on the Navigation menu (Navigation menu icon) click Vertex AI > Dashboard.

  2. Click Enable Vertex AI API.

  3. From the Vertex AI navigation menu on the left, click Datasets.

  4. At the top of the console, click + Create.

  5. For Dataset name, type damaged_car_parts.

  6. Select Image classification (Single label). (Note: in your own projects, you may want to check the "Multi-label Classification" box if you're doing multi-class classification).

  7. Click Create.

Connect your dataset to your training images

In this section, you will choose the location of your training images that you uploaded in the previous step.

  1. In the Select an import method section, click Select import files from Cloud Storage.

  2. In the Select import files from Cloud Storage section, click Browse.

  3. Follow the prompts to navigate to your storage bucket and click your data.csv file. Click Select.

  4. Once you've properly selected your file, a green checkbox appears to the left of the file path. Click Continue to proceed.

Note: It will take around 9 to 12 minutes for your images to import and be aligned with their categories. You’ll need to wait for this step to complete before checking your progress.
  1. Once the import has completed, prepare for the next section by clicking the Browse tab. (Hint: You may need to refresh the page to confirm.)

Click Check my progress to verify the objective. Create a dataset

Task 3. Inspect images

In this task, you examine the images to ensure there are no errors in your dataset.

Image tiles on the Browse tabbed page

Check image labels

  1. If your browser page has refreshed, click Datasets , select your image name, and then click Browse.

  2. Under Filter labels, click any one of the labels to view the specific training images. (Example: engine_compartment.)

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 an image is labeled incorrectly, you can click on it to select the correct label or delete the image from your training set:

Image details

  1. Next, click on the Analyze tab to view the number of images per label. The Label Stats window appears on the right side of your browser.
Note: If you need help labeling your dataset, Vertex AI Labeling Services lets you work with human labelers to generate highly accurate labels.

Task 4. Train your model

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

  1. From the right-hand side, click Train New Model.

  2. From the Training method window, leave the default configurations and select AutoML as the training method. Click Continue.

  3. From the Model details window, enter a name for your model, use: damaged_car_parts_model.

  4. From the Explainability window, click continue and for Compute and pricing window, set your budget to 8 maximum node hours.

  5. Click Start Training.

Note: Model training will take roughly 25 minutes to complete.

Click Check my progress to verify the objective. Train your model

Task 5. Evaluate your model

In this task, you evaluate your model. This will vary based on the metrics you chose for your model. Ideally, you’ll work with a data scientist at this point to verify the accuracy of your model.

  1. Navigate to your newly trained model. Click on the Evaluate tab. This tab displays information about Precision and Recall of the model. It should resemble the following:

Evaluate tabbed page displays an All Labels section, a precision-recall graph, and a precision-recall by threshold graph.

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

  2. Scroll down to view the Confusion matrix.

Confusion matrix

This section provides some common machine learning metrics to help you evaluate your model’s accuracy and identify areas for improvement in your training data.

Task 6. Test your understanding

In this task, answer the following multiple-choice questions to reinforce your understanding of this lab's concepts. Answer the questions to the best of your abilities.

Note: If you wish to explore the accuracy metrics section on your own, here are a few points to keep in mind:
  • The confusion matrix provides insights on the classes (aka labels) that the model is still a little confused about.
  • Everything that is greater than 0 and is outside of the diagonal represents misclassification. These will be highlighted.
  • Use the highlighted boxes as signals to consider collecting more labeled images and to help improve the confidence of the classification.

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.

This can take up to 20 minutes to deploy.

Click Check my progress to verify the objective. Deploy to endpoint

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'll use the UI to upload new images and see how your model classifies the following images:

  • Damaged bumper

  • Damaged engine compartment

  • Damage to the hood and the bumper.

    Note: This last image is a good candidate for a multi-label classification problem.

Add the images below to your model

Download these images to your local machine and then upload them to the model:

  1. Right-click on each image below, then select Save image As…

  2. Follow the prompts to save each image with a unique name. (Hint: Assign a simple name like 'Image1' and 'Image2' to assist with uploading later)

image1 image 2 image 3

  1. In the Cloud console, navigate to the Deploy & Test tab in the Vertex AI UI.

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

Upload Image button under Test your model

  1. 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:

Image prediction for image 1: bumper

Image prediction for image 2: engine_compartment

Image prediction for image 3: hood

How did your model do? Did it predict all three images correctly?


In this lab, you learned how to train your own custom machine learning model and generate predictions on it through the web UI. You uploaded training images to Cloud Storage and used a CSV file for Vertex AI to find these images. You inspected the labeled images for any discrepancies before finally evaluating a trained model. Now you've got what it takes to train a model on your own image dataset.

Finish your quest

This self-paced lab is part of the Build and Deploy Machine Learning Solutions on Vertex AI quest. A quest is a series of related labs that form a learning path. Completing this quest earns you a badge to recognize your achievement. You can make your badge or badges public and link to them in your online resume or social media account. Enroll in this quest and get immediate completion credit. See the Google Cloud Skills Boost catalog to see all available quests.

Take your next lab

Continue the Build and Deploy Machine Learning Solutions on Vertex AI quest with the next lab, Deploy a BigQuery ML Customer Churn Classifier to Vertex AI for Online Predictions.

Next steps / learn more

Google Cloud training and certification

...helps you make the most of Google Cloud technologies. Our classes include technical skills and best practices to help you get up to speed quickly and continue your learning journey. We offer fundamental to advanced level training, with on-demand, live, and virtual options to suit your busy schedule. Certifications help you validate and prove your skill and expertise in Google Cloud technologies.

Manual Last Updated August 17, 2022

Lab Last Tested August 17, 2022

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.