התכונה "מדידה וירטואלית" מאפשרת ליצור תמונות של אנשים כדי למדוד באופן וירטואלי מוצרי ביגוד. אתם מספקים תמונה של אדם ותמונה של מוצר ביגוד, ואז התכונה 'התנסות וירטואלית' יוצרת תמונה של האדם כשהוא לובש את המוצר.
המודלים הבאים תומכים ביצירת תמונות של התנסות וירטואלית:
לחצו כדי להרחיב את רשימת המודלים הנתמכים
לפני שמתחילים
-
In the Cloud de Confiance console, on the project selector page, select or create a Cloud de Confiance 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 Cloud de Confiance project.
Enable the Agent Platform API, if it is not already enabled.
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. 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.-
מגדירים אימות לסביבה.
צריך לבחור את הכרטיסייה הרלוונטית לאופן שבו תכננתם להשתמש בדוגמאות בדף הזה:
Python
כדי להשתמש בסביבת פיתוח מקומית בדוגמאות של Python שבדף הזה, מתקינים ומפעילים את ה-CLI של gcloud, ואז מגדירים את Application Default Credentials באמצעות פרטי הכניסה של המשתמש.
-
התקינו את ה-CLI של Google Cloud.
-
הגדירו שה-CLI של gcloud ישתמש בזהות המאוחדת שלכם.
-
צרו פרטי כניסה לאימות מקומי בחשבון המשתמש:
gcloud auth application-default login
אם מופיעה שגיאת אימות, ודאו ש נכנסתם ל-CLI של gcloud באמצעות הזהות המאוחדת שלכם.
למידע נוסף, ראו הגדרת ADC לסביבת פיתוח מקומית במאמרי העזרה בנושא אימות Cloud de Confiance .
REST
כדי להשתמש בסביבת פיתוח מקומית בדוגמאות של API בארכיטקטורת REST שבדף הזה, צריך להשתמש בפרטי הכניסה שאתם נותנים ל-CLI של gcloud.
התקינו את ה-CLI של Google Cloud ואז היכנסו ל-CLI של gcloud באמצעות הזהות המאוחדת שלכם.
מידע נוסף מופיע במאמר אימות לשימוש ב-REST במסמכי האימות של Cloud de Confiance .
-
יצירת תמונות
Python
התקנה
pip install --upgrade google-genai
מידע נוסף מופיע ב מאמרי העזרה בנושא SDK.
מגדירים משתני סביבה כדי להשתמש ב-Google Gen AI SDK עם Vertex AI:
# Replace the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` values # with appropriate values for your project. export GOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECT export GOOGLE_CLOUD_LOCATION=global export GOOGLE_GENAI_USE_ENTERPRISE=True
REST
מידע נוסף על Virtual Try-On API:
לפני שמשתמשים בנתוני הבקשה, צריך להחליף את הנתונים הבאים:
- REGION: האזור שבו נמצא הפרויקט. מידע נוסף על אזורים נתמכים זמין במאמר פריסות ונקודות קצה.
- PROJECT_ID: מזהה הפרויקט ב- Cloud de Confiance by S3NS .
- BASE64_PERSON_IMAGE: תמונה של האדם בקידוד Base64.
- BASE64_PRODUCT_IMAGE: תמונת המוצר בקידוד Base64.
-
IMAGE_COUNT: מספר התמונות שרוצים ליצור. טווח הערכים הקבילים הוא
1עד4. - GCS_OUTPUT_PATH: הנתיב ב-Cloud Storage שבו יישמר הפלט של ההתנסות הווירטואלית.
ה-method של ה-HTTP וכתובת ה-URL:
POST https://REGION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/REGION/publishers/google/models/virtual-try-on-001:predict
גוף בקשת JSON:
{
"instances": [
{
"personImage": {
"image": {
"bytesBase64Encoded": "BASE64_PERSON_IMAGE"
}
},
"productImages": [
{
"image": {
"bytesBase64Encoded": "BASE64_PRODUCT_IMAGE"
}
}
]
}
],
"parameters": {
"sampleCount": IMAGE_COUNT,
"storageUri": "GCS_OUTPUT_PATH"
}
}
כדי לשלוח את הבקשה עליכם לבחור אחת מהאפשרויות הבאות:
curl
שומרים את גוף הבקשה בקובץ בשם request.json ומריצים את הפקודה הבאה:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://REGION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/REGION/publishers/google/models/virtual-try-on-001:predict"
PowerShell
שומרים את גוף הבקשה בקובץ בשם request.json ומריצים את הפקודה הבאה:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://REGION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/REGION/publishers/google/models/virtual-try-on-001:predict" | Select-Object -Expand Content
{
"predictions": [
{
"mimeType": "image/png",
"bytesBase64Encoded": "BASE64_IMG_BYTES"
},
{
"bytesBase64Encoded": "BASE64_IMG_BYTES",
"mimeType": "image/png"
}
]
}