שלום, הדרכה בהתאמה אישית: הגדרת הפרויקט והסביבה

בדף הזה מוסבר איך להגדיר את הפרויקט ב- Google Cloud כדי להשתמש ב-Gemini Enterprise Agent Platform, ואיך להוריד קוד TensorFlow לאימון. בנוסף, תורידו קוד לאפליקציית אינטרנט שמקבלת חיזויים.

המדריך הזה כולל כמה דפים:

  1. הגדרת הפרויקט והסביבה.

  2. אימון מודל בהתאמה אישית לסיווג תמונות

  3. הצגת חיזויים ממודל מותאם אישית לסיווג תמונות.

  4. פינוי מקום בפרויקט

בכל דף מניחים שכבר ביצעתם את ההוראות מהדפים הקודמים של המדריך.

לפני שמתחילים

במדריך הזה משתמשים במסוף Google Cloud וב-Cloud Shell כדי ליצור אינטראקציה עם Google Cloud. במקום Cloud Shell, אתם יכולים להשתמש במעטפת Bash אחרת שמותקן בה Google Cloud CLI.

  1. נכנסים לחשבון Google Cloud . אנחנו ממליצים למשתמשים חדשים ב- Google Cloud ליצור חשבון כדי שיוכלו להעריך את הביצועים של המוצרים שלנו בתרחישים מהעולם האמיתי. לקוחות חדשים מקבלים בחינם גם קרדיט בשווי 300$ להרצה, לבדיקה ולפריסה של עומסי העבודה.
  2. 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 the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  3. Verify that billing is enabled for your Google Cloud project.

  4. 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.enable permission. 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.

    Enable the APIs

  5. 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 the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  6. Verify that billing is enabled for your Google Cloud project.

  7. 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.enable permission. 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.

    Enable the APIs

  8. מפעילים את Cloud Shell במסוף Google Cloud .

    הפעלת Cloud Shell

    בחלק התחתון של מסוף Google Cloud יתחיל סשן של Cloud Shell ותופיע הודעה של שורת הפקודה. Cloud Shell היא סביבת מעטפת שבה ה-CLI של Google Cloud מותקן ומוגדרים ערכים לפרויקט הקיים. הסשן יופעל תוך כמה שניות.

  9. אם לא מופיע (PROJECT_ID)$ בהנחיה של Cloud Shell (כאשר 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

מחליפים את מה שכתוב בשדות הבאים:

הורדת קוד לדוגמה

מורידים קוד לדוגמה לשימוש בשאר חלקי המדריך.

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.

המאמרים הבאים

כדי להריץ משימת אימון בהתאמה אישית ב-Agent Platform, פועלים לפי ההוראות בדף הבא במדריך.