Entraînement personnalisé Hello : configurer votre projet et votre environnement
Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Cette page explique comment configurer votre projet Google Cloud pour utiliser Vertex AI et télécharger du code TensorFlow pour l'entraînement. Vous allez également télécharger le code d'une application Web qui obtient des prédictions.
Chaque page suppose que vous avez déjà effectué les instructions des pages précédentes du tutoriel.
Avant de commencer
Tout au long de ce tutoriel, vous utiliserez Google Cloud Console et Cloud Shell pour interagir avec Google Cloud. Sinon, au lieu de Cloud Shell, vous pouvez utiliser un autre shell Bash lorsque la Google Cloud CLI est installée.
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 n'affiche pas (PROJECT_ID)$ dans son invite (où PROJECT_ID est remplacé par l'ID de votre projet Google Cloud), exécutez la commande suivante pour configurer Cloud Shell de manière à utiliser votre projet :
gcloudconfigsetprojectPROJECT_ID
Créer un bucket Cloud Storage
Dans la région us-central1, créez un bucket Cloud Storage régional à utiliser pour la suite de ce tutoriel. Pendant ce tutoriel, vous utiliserez le bucket à plusieurs fins :
Stockez le code d'entraînement à utiliser par Vertex AI dans une tâche d'entraînement personnalisée.
Stocker des artefacts de modèle générés par votre tâche d'entraînement personnalisé.
Hébergez l'application Web qui obtient les prédictions à partir de votre point de terminaison Vertex AI.
Pour créer le bucket Cloud Storage, exécutez la commande suivante dans votre session Cloud Shell :
Pour afficher les exemples de fichiers de code, exécutez la commande suivante:
ls-lpRhello-custom-sample
Le répertoire hello-custom-sample contient quatre éléments :
trainer/ : répertoire du code TensorFlow Keras pour l'entraînement du modèle de classification de fleurs.
setup.py : fichier de configuration permettant d'empaqueter le répertoire trainer/ dans une distribution source Python que Vertex AI peut utiliser.
function/ : répertoire de code Python pour une fonction Cloud Run permettant de recevoir et prétraiter les requêtes de prédiction à partir d'un navigateur Web, de les envoyer à Vertex AI, de traiter les réponses de prédiction et de les renvoyer au navigateur.
webapp/ : répertoire contenant le code et le balisage d'une application Web qui obtient des prédictions de classification de fleurs à partir de Vertex AI.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/04 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 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."]]