가상 테스트를 사용하면 의류 제품을 가상으로 입어보는 사람의 이미지를 생성할 수 있습니다. 사람 이미지와 의류 제품 이미지를 제공하면 가상 체험에서 해당 제품을 착용한 사람의 이미지를 생성합니다.
시작하기 전에
- 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.
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
(
roles/resourcemanager.projectCreator
), which contains theresourcemanager.projects.create
permission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
-
Enable the Vertex AI API.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin
), which contains theserviceusage.services.enable
permission. 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
(
roles/resourcemanager.projectCreator
), which contains theresourcemanager.projects.create
permission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
-
Enable the Vertex AI API.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin
), which contains theserviceusage.services.enable
permission. Learn how to grant roles. -
환경에 대한 인증을 설정하세요.
Select the tab for how you plan to use the samples on this page:
Python
로컬 개발 환경에서 이 페이지의 Python 샘플을 사용하려면 gcloud CLI를 설치하고 초기화한 후 사용자 인증 정보로 애플리케이션 기본 사용자 인증 정보를 설정합니다.
Google Cloud CLI를 설치합니다.
외부 ID 공급업체(IdP)를 사용하는 경우 먼저 제휴 ID로 gcloud CLI에 로그인해야 합니다.
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
자세한 내용은 Google Cloud 인증 문서의 로컬 개발 환경의 ADC 설정을 참조하세요.
REST
로컬 개발 환경에서 이 페이지의 REST API 샘플을 사용하려면 gcloud CLI에 제공한 사용자 인증 정보를 사용합니다.
Google Cloud CLI를 설치합니다.
외부 ID 공급업체(IdP)를 사용하는 경우 먼저 제휴 ID로 gcloud CLI에 로그인해야 합니다.
자세한 내용은 Google Cloud 인증 문서의 REST 사용을 위한 인증을 참조하세요.
이미지 생성
Python
설치
pip install --upgrade google-genai
자세한 내용은 SDK 참고 문서를 참조하세요.
Vertex AI에서 Gen AI SDK를 사용하도록 환경 변수를 설정합니다.
# 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_VERTEXAI=True
REST
요청 데이터를 사용하기 전에 다음을 바꿉니다.
- REGION: 프로젝트가 있는 리전. 지원되는 리전에 대한 자세한 내용은 Vertex AI의 생성형 AI 위치를 참조하세요.
- PROJECT_ID: Google Cloud 프로젝트 ID
- BASE64_PERSON_IMAGE: 사람 이미지의 Base64 인코딩 이미지
- BASE64_PRODUCT_IMAGE: 제품 이미지의 Base64 인코딩 이미지
-
IMAGE_COUNT: 생성할 이미지 수. 허용되는 값의 범위는
1
~4
입니다. - GCS_OUTPUT_PATH: 가상 테스트 출력을 저장할 Cloud Storage 경로
HTTP 메서드 및 URL:
POST https://REGION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/REGION/publishers/google/models/virtual-try-on-preview-08-04: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-preview-08-04: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-preview-08-04:predict" | Select-Object -Expand Content{ "predictions": [ { "mimeType": "image/png", "bytesBase64Encoded": "BASE64_IMG_BYTES" }, { "bytesBase64Encoded": "BASE64_IMG_BYTES", "mimeType": "image/png" } ] }
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-09-30(UTC)