Train and Deploy an AutoML Image Classification Model with Vertex AI
This tutorial guides you through the process of using Vertex AI to train and deploy an AutoML Image Classification model. You'll use a public flower image dataset, train the model using AutoML, evaluate its performance, deploy it to an endpoint, and send predictions โ all from the Google Cloud Console.
๐งฑ Step 1: Set Up Your Google Cloud Projectโ
Select or Create a Projectโ
- Visit the Google Cloud Console project selector.
- Choose an existing project or create a new one for this tutorial.
๐ก Tip: If you don't plan to retain the resources, create a new project so cleanup is easier.
Open Cloud Shellโ
Click the Activate Cloud Shell button in the top-right of the console. Once ready, set your project ID:
gcloud config set project PROJECT_ID
export projectid=PROJECT_ID
echo $projectid
Replace PROJECT_ID with your actual project identifier.
๐ง Step 2: Enable Required APIsโ
Run the following command in Cloud Shell:
gcloud services enable iam.googleapis.com compute.googleapis.com notebooks.googleapis.com storage.googleapis.com aiplatform.googleapis.com
๐ Step 3: Set IAM Permissionsโ
Grant the necessary IAM roles:
gcloud projects add-iam-policy-binding PROJECT_ID --member="user:your-email@example.com" --role=roles/aiplatform.user
gcloud projects add-iam-policy-binding PROJECT_ID --member="user:your-email@example.com" --role=roles/storage.admin
These permissions allow you to use Vertex AI and access Cloud Storage for dataset management.
๐๏ธ Step 4: Create and Import Image Datasetโ
Open Vertex AI > Datasetsโ
- Click Create Dataset.
- Select Image as the data type.
- Choose Image Classification (Single-label).
- Set region to us-central1.
- Enter a name for the dataset (optional).
- Click Create.
Import Data from Cloud Storageโ
Use this public CSV containing image URIs and labels:
cloud-samples-data/ai-platform/flowers/flowers.csv
This CSV includes rows like:
gs://cloud-samples-data/ai-platform/flowers/daisy/10559679065_50d2b16f6d.jpg,daisy
gs://cloud-samples-data/ai-platform/flowers/dandelion/10828951106_c3cd47983f.jpg,dandelion
๐ You'll see a preview of your images and labels after import completes (takes a few minutes).
๐ง Step 5: Train AutoML Modelโ
- Go to the Models section.
- Click Train new model.
- Select:
- Training method: AutoML
- Target dataset: Your image dataset
- (Optional) Name your model.
- Define training options:
- Training budget: 8 node hours
- Enable Incremental Training: Only if you have a base model
- Click Start training.
๐ฌ Youโll get an email notification when training finishes (can take several hours).
๐ Step 6: Evaluate Modelโ
Navigate to the Evaluate tab of your model:
- View key metrics:
- Precision
- Recall
- Confusion Matrix
- Analyze false positives, false negatives, and true positives.
- Use Review Similar Images to find label inconsistencies or outliers.
๐ Fix incorrect labels and re-train if needed to improve accuracy.
๐ Step 7: Deploy Model to Endpointโ
- Go to Deploy & Test tab.
- Click Deploy to Endpoint.
- Choose:
- Create New Endpoint
- Name: image-classification
- Traffic Split: 100%
- Compute Nodes: 1
- Click Deploy.
Deployment takes a few minutes.
๐งช Step 8: Send a Predictionโ
After deployment:
- Go to Deploy & Test > Test your model.
- Click Upload Image.
- Choose a local image.
- View the predicted label and confidence.
๐งน Step 9: Clean Up Resourcesโ
To avoid charges, delete the resources:
Undeploy Modelโ
Vertex AI > Models > Deploy & Test > Undeploy
Delete Endpointโ
Vertex AI > Endpoints > Delete image-classification
9.3 Delete Model and Datasetโ
Vertex AI > Models > Delete
Vertex AI > Datasets > Delete
Delete Cloud Storage Bucketโ
Go to Cloud Storage and delete your bucket.
๐ Summaryโ
- โ Created dataset with labeled images
- โ Trained an AutoML image classification model
- โ Evaluated model performance
- โ Deployed to a live endpoint
- โ Sent predictions and cleaned up
Vertex AI simplifies machine learning workflows with a UI-based AutoML approach. Stay tuned for more advanced tutorials on custom training, multi-class classification, and model explainability.
๐ก "Teaching AI has never been easier. With Vertex AI, all you need is your data."