Entrenamiento personalizado de Hello: configura tu proyecto y entorno
Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
En esta página, se explica cómo configurar tu proyecto Google Cloud para usar Vertex AI y descargar código de TensorFlow para el entrenamiento. También descargarás un código de aplicación web que obtiene predicciones.
En este instructivo, se incluyen las siguientes páginas:
En cada página, se supone que ya realizaste las instrucciones de las páginas anteriores del instructivo.
Antes de comenzar
Durante este instructivo, usa la Google Cloud consola y Cloud Shell para interactuar con Google Cloud. Como alternativa, en lugar de Cloud Shell, puedes usar otro shell de Bash con Google Cloud CLI instalada.
Sign in to your Google Cloud account. If you're new to
Google Cloud,
create an account to evaluate how our products perform in
real-world scenarios. New customers also get $300 in free credits to
run, test, and deploy workloads.
In the Google Cloud console, on the project selector page,
select or create a Google Cloud project.
At the bottom of the Google Cloud 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.
Si Cloud Shell no muestra (PROJECT_ID)$ en su mensaje (donde PROJECT_ID se reemplaza por el ID de tu proyecto de Google Cloud ), ejecuta el siguiente comando para configurar Cloud Shell para usar tu proyecto:
gcloudconfigsetprojectPROJECT_ID
Cree un bucket de Cloud Storage
Crea un bucket regional de Cloud Storage en la región us-central1 para usar en el resto de este instructivo. A medida que sigues el instructivo, usa el bucket para diversos propósitos:
Almacena código de entrenamiento para que Vertex AI lo use en un trabajo de entrenamiento personalizado.
Almacena los artefactos del modelo que genera tu trabajo de entrenamiento personalizado.
Aloja la app web que obtiene predicciones de tu extremo de Vertex AI.
Para crear el bucket de Cloud Storage, ejecuta el siguiente comando en tu sesión de Cloud Shell:
Para ver los archivos de código de muestra de manera opcional, ejecuta el siguiente comando:
ls-lpRhello-custom-sample
El directorio hello-custom-sample tiene cuatro elementos:
trainer/: Un directorio del código de Keras de TensorFlow para entrenar el modelo de clasificación de flores.
setup.py: Un archivo de configuración para empaquetar el directorio trainer/ en una distribución de fuente de Python que Vertex AI puede usar.
function/: Un directorio de código de Python para una función de Cloud Run que puede recibir y procesar de forma previa solicitudes de predicción desde un navegador web, enviarlas a Vertex AI, procesar las respuestas de predicción y enviarlas al navegador.
webapp/: Un directorio con código y lenguaje de marcado para una aplicación web que obtiene predicciones de clasificación de flores de Vertex AI.
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Información o código de muestra incorrectos","incorrectInformationOrSampleCode","thumb-down"],["Faltan la información o los ejemplos que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2025-09-04 (UTC)"],[],[],null,["# Hello custom training: Set up your project and environment\n\nThis page walks through setting up your Google Cloud project to use\nVertex AI and downloading some TensorFlow code for training. You will\nalso download code for a web app that gets predictions.\nThis tutorial has several pages:\n\n\u003cbr /\u003e\n\n1. Setting up your project and environment.\n\n2. [Training a custom image classification\n model.](/vertex-ai/docs/tutorials/image-classification-custom/training)\n\n3. [Serving predictions from a custom image classification\n model.](/vertex-ai/docs/tutorials/image-classification-custom/serving)\n\n4. [Cleaning up your project.](/vertex-ai/docs/tutorials/image-classification-custom/cleanup)\n\nEach page assumes that you have already performed the instructions from the\nprevious pages of the tutorial.\n\nBefore you begin\n----------------\n\nThroughout this tutorial, use Google Cloud console and\n[Cloud Shell](/shell/docs) to interact with Google Cloud. Alternatively,\ninstead of Cloud Shell, you\ncan use another Bash shell with the [Google Cloud CLI](/sdk/docs) installed.\n\n- Sign in to your Google Cloud account. If you're new to Google Cloud, [create an account](https://console.cloud.google.com/freetrial) to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.\n- In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\n-\n\n\n Enable the Vertex AI and Cloud Run functions APIs.\n\n\n [Enable the APIs](https://console.cloud.google.com/flows/enableapi?apiid=aiplatform.googleapis.com,cloudfunctions)\n\n- In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\n-\n\n\n Enable the Vertex AI and Cloud Run functions APIs.\n\n\n [Enable the APIs](https://console.cloud.google.com/flows/enableapi?apiid=aiplatform.googleapis.com,cloudfunctions)\n\n1. In the Google Cloud console, activate Cloud Shell.\n\n [Activate Cloud Shell](https://console.cloud.google.com/?cloudshell=true)\n\n\n At the bottom of the Google Cloud console, a\n [Cloud Shell](/shell/docs/how-cloud-shell-works)\n session starts and displays a command-line prompt. Cloud Shell is a shell environment\n with the Google Cloud CLI\n already installed and with values already set for\n your current project. It can take a few seconds for the session to initialize.\n2. If Cloud Shell does not display\n `(`\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e`)$`\n in its prompt (where \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e is replaced by your\n Google Cloud project ID), then run the following command to\n configure Cloud Shell to use your project:\n\n gcloud config set project \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e\n\nCreate a Cloud Storage bucket\n-----------------------------\n\nCreate a regional [Cloud Storage](/storage/docs) bucket in the `us-central1`\nregion to use for the rest of this tutorial. As you follow the tutorial, use the\nbucket for several purposes:\n\n- Store training code for Vertex AI to use in a custom training job.\n- Store the model artifacts that your custom training job outputs.\n- Host the web app that gets predictions from your Vertex AI endpoint.\n\nTo create the Cloud Storage bucket, run the following command in your\nCloud Shell session: \n\n gcloud storage buckets create gs://\u003cvar translate=\"no\"\u003eBUCKET_NAME\u003c/var\u003e --project=\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e --location=us-central1\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: The ID of your Google Cloud project.\n- \u003cvar translate=\"no\"\u003eBUCKET_NAME\u003c/var\u003e: A name that you choose for your bucket. For example, `hello_custom_`\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e. Learn about [requirements for bucket\n names](/storage/docs/buckets#naming).\n\nDownload sample code\n--------------------\n\nDownload sample code to use for the rest of the tutorial. \n\n gcloud storage cp gs://cloud-samples-data/ai-platform/hello-custom/hello-custom-sample-v1.tar.gz - | tar -xzv\n\nTo optionally view the sample code files, run the following command: \n\n ls -lpR hello-custom-sample\n\nThe `hello-custom-sample` directory has four items:\n\n- `trainer/`: A directory of TensorFlow Keras code for training the flower\n classification model.\n\n- `setup.py`: A configuration file for packaging the `trainer/` directory into\n a Python source distribution that Vertex AI can use.\n\n- `function/`: A directory of Python code for a\n [Cloud Run function](/functions/docs) that can receive and preprocess\n prediction requests from a web browser, send them to Vertex AI,\n process the prediction responses, and send them back to the browser.\n\n- `webapp/`: A directory with code and markup for a web app that gets flower\n classification predictions from Vertex AI.\n\nWhat's next\n-----------\n\nFollow the [next page of this tutorial](/vertex-ai/docs/tutorials/image-classification-custom/training) to run a custom\ntraining job on Vertex AI."]]