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."