Hello custom training: Train a custom image classification model Stay organized with collections Save and categorize content based on your preferences.
To learn more, run the following notebooks in the environment of your choice:
"Use the Vertex AI SDK for Python to train and deploy a custom image classification model for batch prediction.":
Open in Colab |Open in Colab Enterprise |Openin Vertex AI Workbench |View on GitHub
"Use the Vertex AI SDK for Python to train and deploy a custom image classification model for online prediction.":
Open in Colab |Open in Colab Enterprise |Openin Vertex AI Workbench |View on GitHub
This page shows you how to run a TensorFlow Keras training application onVertex AI. This particular model trains an image classificationmodel that can classify flowers by type.
This tutorial has several pages:Training a custom image classification model.
Serving predictions from a custom image classificationmodel.
Each page assumes that you have already performed the instructions from theprevious pages of the tutorial.
The rest of this document assumes that you are using the same Cloud Shellenvironment that you created when following thefirst page of thistutorial. If your original Cloud Shell session is nolonger open, you can return to the environment by doing the following:In the Google Cloud console, activate Cloud Shell.
In the Cloud Shell session, run the following command:
cdhello-custom-sample
Run a custom training pipeline
This section describes using the training package that you uploaded toCloud Storage to run a Vertex AI custom trainingpipeline.
In the Google Cloud console, in the Vertex AI section, go totheTraining pipelines page.
ClickCreate to open theTrain new model pane.
On theChoose training method step, do the following:
In theDataset drop-down list, selectNo managed dataset. Thisparticular training application loads data from theTensorFlowDatasets library rather than a managed Vertex AIdataset.
Ensure thatCustom training (advanced) is selected.
ClickContinue.
On theModel details step, in theName field, enter
hello_custom. ClickContinue.On theTraining container step, provide Vertex AI withinformation it needs to use the training package that you uploaded toCloud Storage:
SelectPrebuilt container.
In theModel framework drop-down list, selectTensorFlow.
In theModel framework version drop-down list, select2.3.
In thePackage location field, enter
cloud-samples-data/ai-platform/hello-custom/hello-custom-sample-v1.tar.gz.In thePython module field, enter
trainer.task.traineris thename of the Python package in your tarball, andtask.pycontains yourtraining code. Therefore,trainer.taskis the name of the module thatyou want Vertex AI to run.In theModel output directory field, clickBrowse. Do thefollowing in theSelect folder pane:
Navigate to your Cloud Storage bucket.
ClickCreate new folder
create_new_folder .Name the new folder
output. Then clickCreate.ClickSelect.
Confirm that field has the value
gs://BUCKET_NAME/output, whereBUCKET_NAMEis the name of your Cloud Storage bucket.This value gets passed to Vertex AI in the
baseOutputDirectoryAPIfield, which setsseveral environment variables that your training application can accesswhen it runs.For example, when you set this field to
gs://BUCKET_NAME/output, Vertex AI setstheAIP_MODEL_DIRenvironment variable togs://BUCKET_NAME/output/model. At the end of training,Vertex AI uses any artifacts in theAIP_MODEL_DIRdirectoryto create a model resource.Learn more about theenvironment variables set by thisfield.
ClickContinue.
On the optionalHyperparameters step, make sure that theEnablehyperparameter tuning checkbox is cleared. This tutorial does not usehyperparameter tuning. ClickContinue.
On theCompute and pricing step, allocate resources for the customtraining job:
In theRegion drop-down list, selectus-central1 (Iowa).
In theMachine type drop-down list, selectn1-standard-4 from theStandard section.
Do not add any accelerators or worker pools for this tutorial. ClickContinue.
On thePrediction container step, provide Vertex AI withinformation it needs to serve predictions:
SelectPrebuilt container.
In thePrebuilt container settings section, do the following:
In theModel framework drop-down list, selectTensorFlow.
In theModel framework version drop-down list, select2.3.
In theAccelerator type drop-down list, selectNone.
Confirm thatModel directory field has the value
gs://BUCKET_NAME/output, whereBUCKET_NAME is the name of your Cloud Storagebucket. This matches theModel output directory value that youprovided in a previous step.
Leave the fields in thePredict schemata section blank.
ClickStart training to start the custom training pipeline.
You can now view your newtraining pipeline, which is namedhello_custom, ontheTraining page. (You might need to refresh the page.) The trainingpipeline does two main things:
The training pipeline creates acustom job resource named
hello_custom-custom-job. After a few moments, you can view this resourceon theCustom jobs page of theTraining section:The custom job runs the training application using the computing resourcesthat you specified in this section.
After the custom job completes, the training pipeline finds the artifactsthat your training application creates in the
output/model/directory ofyour Cloud Storage bucket. It uses these artifacts to createamodel resource.
Monitor training
To view training logs, do the following:
In the Google Cloud console, in the Vertex AI section, go totheCustom jobs page.
To view details for the
CustomJobthat you just created, clickhello_custom-custom-jobin the list.On the job details page, clickView logs.
View your trained model
When the custom training pipeline completes, you can find the trained model inthe Google Cloud console, in the Vertex AI section, on theModels page.
The model has the namehello_custom.
What's next
Follow thenext page of this tutorial to servepredictions from your trained ML model.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-02-18 UTC.
Open in Colab
Open in Colab Enterprise
Openin Vertex AI Workbench
View on GitHub