This page walks through setting up your Cloud de Confiance by S3NS project to use Gemini Enterprise Agent Platform and downloading some TensorFlow code for training. You will also download code for a web app that gets predictions.
This tutorial has several pages:Setting up your project and environment.
Serving predictions from a custom image classification model.
Each page assumes that you have already performed the instructions from the previous pages of the tutorial.
Before you begin
Throughout this tutorial, use Cloud de Confiance console and Cloud Shell to interact with Cloud de Confiance by S3NS. Alternatively, instead of Cloud Shell, you can use another Bash shell with the Google Cloud CLI installed.
-
In the Cloud de Confiance console, on the project selector page, select or create a Cloud de Confiance project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Cloud de Confiance project.
Enable the Gemini Enterprise Agent Platform and Cloud Run functions APIs, if any are not already enabled.
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.-
In the Cloud de Confiance console, activate Cloud Shell.
At the bottom of the Cloud de Confiance console, a Cloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize.
-
If Cloud Shell does not display
(PROJECT_ID)$in its prompt (where PROJECT_ID is replaced by your Cloud de Confiance project ID), then run the following command to configure Cloud Shell to use your project:gcloud config set project PROJECT_ID
Create a Cloud Storage bucket
Create a regional Cloud Storage bucket in the us-central1
region to use for the rest of this tutorial. As you follow the tutorial, use the
bucket for several purposes:
- Store training code for Agent Platform to use in a custom training job.
- Store the model artifacts that your custom training job outputs.
- Host the web app that gets predictions from your Agent Platform endpoint.
To create the Cloud Storage bucket, run the following command in your Cloud Shell session:
gcloud storage buckets create gs://BUCKET_NAME --project=PROJECT_ID --location=us-central1
Replace the following:
- PROJECT_ID: The ID of your Cloud de Confiance project.
- BUCKET_NAME: A name that you choose for your bucket. For example,
hello_custom_PROJECT_ID. Learn about requirements for bucket names.
Download sample code
Download sample code to use for the rest of the tutorial.
gcloud storage cp gs://cloud-samples-data/ai-platform/hello-custom/hello-custom-sample-v1.tar.gz - | tar -xzv
To optionally view the sample code files, run the following command:
ls -lpR hello-custom-sample
The hello-custom-sample directory has four items:
trainer/: A directory of TensorFlow Keras code for training the flower classification model.setup.py: A configuration file for packaging thetrainer/directory into a Python source distribution that Agent Platform can use.function/: A directory of Python code for a Cloud Run function that can receive and preprocess prediction requests from a web browser, send them to Agent Platform, process the prediction responses, and send them back to the browser.webapp/: A directory with code and markup for a web app that gets flower classification predictions from Agent Platform.
What's next
Follow the next page of this tutorial to run a custom training job on Agent Platform.