Pelatihan kustom Hello: Menyiapkan project dan lingkungan Anda
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Halaman ini berisi penjelasan mengenai penyiapan project Google Cloud untuk menggunakan
Vertex AI dan mendownload beberapa kode TensorFlow untuk pelatihan. Anda juga akan
mendownload kode untuk aplikasi web yang mendapatkan prediksi.
Setiap halaman mengasumsikan bahwa Anda telah menjalankan petunjuk dari
halaman sebelumnya dalam tutorial ini.
Sebelum memulai
Dalam tutorial ini, gunakan konsol Google Cloud dan
Cloud Shell untuk berinteraksi dengan Google Cloud. Atau, sebagai pengganti Cloud Shell, Anda dapat menggunakan shell Bash lain dengan Google Cloud CLI yang sudah terinstal.
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.
Jika Cloud Shell tidak menampilkan
(PROJECT_ID)$
dalam perintahnya (dalam hal ini PROJECT_ID diganti dengan
Google Cloud project ID), jalankan perintah berikut untuk
mengonfigurasi Cloud Shell dan menggunakan project Anda:
gcloudconfigsetprojectPROJECT_ID
Membuat bucket Cloud Storage
Buat bucket Cloud Storage regional di region us-central1
untuk digunakan selama tutorial ini. Saat mengikuti tutorial, gunakan
bucket untuk beberapa tujuan:
Menyimpan kode pelatihan untuk Vertex AI yang akan digunakan dalam tugas
pelatihan kustom.
Menyimpan artefak model yang dihasilkan tugas pelatihan kustom Anda.
Menghosting aplikasi web yang mendapatkan prediksi dari
endpoint Vertex AI Anda.
Untuk membuat bucket Cloud Storage, jalankan perintah berikut di
sesi Cloud Shell:
Untuk melihat file kode contoh secara opsional, jalankan perintah berikut:
ls-lpRhello-custom-sample
Direktori hello-custom-sample memiliki empat item:
trainer/: Direktori kode TensorFlow Keras untuk melatih model klasifikasi
bunga.
setup.py: File konfigurasi untuk memaketkan direktori trainer/ ke dalam
distribusi sumber Python yang dapat digunakan Vertex AI.
function/: Direktori kode Python untuk
fungsi Cloud Run yang dapat menerima dan melakukan prapemrosesan
permintaan prediksi dari browser web, mengirimkannya ke Vertex AI,
memproses respons prediksi, dan mengirimkannya kembali ke browser.
webapp/: Direktori dengan kode dan markup untuk aplikasi web yang mendapatkan prediksi klasifikasi
bunga dari Vertex AI.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-08-19 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."]]