בדף הזה נסביר איך להגדיר את הפרויקט כדי להשתמש ב-Gemini Enterprise Agent Platform ולהוריד קוד TensorFlow לאימון. Google Cloud תורידו גם קוד לאפליקציית אינטרנט שמקבלת תחזיות.
המדריך הזה כולל כמה דפים:הגדרת הפרויקט והסביבה.
בכל דף מניחים שכבר ביצעתם את ההוראות מהדפים הקודמים של המדריך.
לפני שמתחילים
במהלך המדריך הזה, תשתמשו במסוף Google Cloud וב-Cloud Shell כדי ליצור אינטראקציה עם Google Cloud. לחלופין, במקום Cloud Shell, אפשר להשתמש במעטפת Bash אחרת עם Google Cloud CLI מותקן.
- נכנסים לחשבון Google Cloud . אם אתם משתמשים חדשים ב- Google Cloud, צרו חשבון כדי שתוכלו להעריך את הביצועים של המוצרים שלנו בתרחישים מהעולם האמיתי. לקוחות חדשים מקבלים בחינם גם קרדיט בשווי 300$ להרצה, לבדיקה ולפריסה של עומסי העבודה.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud 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 Google Cloud project.
Enable the Gemini Enterprise Agent Platform and Cloud Run functions APIs.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission. Learn how to grant roles.-
In the Google Cloud console, on the project selector page, select or create a Google Cloud 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 Google Cloud project.
Enable the Gemini Enterprise Agent Platform and Cloud Run functions APIs.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission. Learn how to grant roles.-
במסוף Google Cloud , מפעילים את Cloud Shell.
בחלק התחתון של Google Cloud המסוף יתחיל סשן של Cloud Shell ותופיע הודעה של שורת הפקודה. Cloud Shell היא סביבת מעטפת שבה ה-CLI של Google Cloud מותקן ומוגדרים ערכים לפרויקט הקיים. הסשן יופעל תוך כמה שניות.
-
אם Cloud Shell לא מציג את
(PROJECT_ID)$בהנחיה שלו (כאשר PROJECT_ID מוחלף במזהה הפרויקט Google Cloud ), מריצים את הפקודה הבאה כדי להגדיר את Cloud Shell להשתמש בפרויקט:gcloud config set project PROJECT_ID
יצירת קטגוריה של Cloud Storage
יוצרים קטגוריה אזורית של Cloud Storage באזור us-central1, כדי להשתמש בה בהמשך המדריך. במהלך המדריך, תשתמשו בדלי למספר מטרות:
- אחסון קוד אימון לשימוש ב-Agent Platform במשימת אימון בהתאמה אישית.
- שמירת ארטיפקטים של המודל שנוצרו על ידי משימת האימון בהתאמה אישית.
- מארחים את אפליקציית האינטרנט שמקבלת תחזיות מנקודת הקצה של Agent Platform.
כדי ליצור את הקטגוריה של Cloud Storage, מריצים את הפקודה הבאה בסשן של Cloud Shell:
gcloud storage buckets create gs://BUCKET_NAME --project=PROJECT_ID --location=us-central1
מחליפים את מה שכתוב בשדות הבאים:
- PROJECT_ID: מזהה הפרויקט ב- Google Cloud .
- BUCKET_NAME: שם שאתם בוחרים לקטגוריה. לדוגמה,
hello_custom_PROJECT_ID. מידע על הדרישות בנוגע לשמות של קטגוריות
הורדת קוד לדוגמה
מורידים קוד לדוגמה לשימוש בהמשך המדריך.
gcloud storage cp gs://cloud-samples-data/ai-platform/hello-custom/hello-custom-sample-v1.tar.gz - | tar -xzv
כדי להציג את קובצי דוגמת הקוד, מריצים את הפקודה הבאה:
ls -lpR hello-custom-sample
בספרייה hello-custom-sample יש ארבעה פריטים:
trainer/: ספרייה של קוד TensorFlow Keras לאימון מודל לסיווג פרחים.
setup.py: קובץ תצורה לאריזת הספרייהtrainer/בחבילת הפצה של קוד מקור של Python, ש-Agent Platform יכולה להשתמש בה.
function/: ספרייה של קוד Python לפונקציית Cloud Run שיכולה לקבל בקשות לחיזוי ולבצע בהן עיבוד מקדים מדפדפן אינטרנט, לשלוח אותן ל-Agent Platform, לעבד את התגובות לחיזוי ולשלוח אותן בחזרה לדפדפן.
webapp/: ספרייה עם קוד ותגי עיצוב לאפליקציית אינטרנט שמקבלת תחזיות לסיווג פרחים מ-Agent Platform.
המאמרים הבאים
כדי להריץ משימת אימון מותאמת אישית בפלטפורמת הסוכנים, צריך לפעול לפי ההוראות בדף הבא של המדריך הזה.