Vertex AI 기반 Imagen을 사용하여 이미지를 업스케일링할 수 있습니다. 그러면 이미지 품질 저하 없이 이미지 크기를 확대할 수 있습니다.
다음 모델은 이미지 업스케일링을 지원합니다.
시작하기 전에
- 계정에 로그인합니다. Google Cloud 를 처음 사용하는 경우 계정을 만들고 Google 제품의 실제 성능을 평가해 보세요. 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 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.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 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.enablepermission. Learn how to grant roles.-
환경에 대한 인증을 설정하세요.
이 페이지의 샘플 사용 방법에 대한 탭을 선택하세요.
콘솔
콘솔을 사용하여서비스 및 API에 액세스하는 경우 인증을 설정할 필요가 없습니다. Google Cloud Google Cloud
REST
로컬 개발 환경에서 이 페이지의 REST API 샘플을 사용하려면 gcloud CLI에 제공한 사용자 인증 정보를 사용합니다.
Google Cloud CLI를 설치합니다.
외부 ID 공급업체 (IdP)를 사용하는 경우 먼저 제휴 ID로 gcloud CLI에 로그인해야 합니다.
자세한 내용은 인증 문서의 REST 사용을 위한 인증 을 참조하세요. Google Cloud
이미지 확대
REST
Imagen API에 대한 자세한 내용은 다음을 참고하세요.
- 메서드:
endpoints.predict VisionGenerativeModelInstanceVisionGenerativeModelParamsVisionGenerativeModelResult
요청 데이터를 사용하기 전에 다음을 바꿉니다.
-
REGION: 프로젝트가 있는 리전. 지원되는 리전에 대한 자세한 내용은 Vertex AI 위치의 생성형 AI를 참조하세요. -
PROJECT_ID: Google Cloud 프로젝트 ID입니다. -
BASE64_SUBJECT_IMAGE: 피사체 이미지의 base64로 인코딩된 이미지입니다. -
ADD_WATERMARK: 선택적 불리언 값입니다. 워터마크가 추가된 이미지를 사용 설정하려면true로 설정하고, 워터마크가 추가된 이미지를 사용 중지하려면false로 설정합니다. 기본값은true입니다. -
GCS_IMAGE_PATH: 이미지 파일의 Cloud Storage 경로입니다. -
GCS_OUTPUT_PATH: 생성된 출력을 저장할 Cloud Storage 경로입니다. -
OUTPUT_MIMETYPE: 이미지의 출력 파일 형식을 정의하는 선택적 문자열입니다. 허용되는 값은"image/png"또는"image/jpeg"입니다. 기본값은"image/png"입니다. -
COMPRESSION_QUALITY: 모델이 JPEG 이미지에 대해 보존하는 세부 수준을 지정하는 선택적 정수 값입니다. 허용되는 값의 범위는0~100입니다. 값이 클수록 압축 수준이 높아집니다. 기본값은75입니다. -
UPSCALE_FACTOR: 확대된 이미지의 배율입니다. 업스케일링 요소를 적용한 후 이미지의 최종 출력 해상도는 17 메가픽셀을 초과해서는 안 됩니다. 허용되는 값은 다음과 같습니다."x2""x3""x4"
HTTP 메서드 및 URL:
POST https://aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/REGION/publishers/google/models/imagen-4.0-upscale-preview:predict
JSON 요청 본문:
{
"instances": [
{
"prompt": "Upscale the image",
"image": {
// use one of the following to specify the image to upscale
"bytesBase64Encoded": "BASE64_SUBJECT_IMAGE"
"gcsUri": "GCS_IMAGE_PATH"
// end of base image input options
},
}
],
"parameters": {
"mode": "upscale",
"storageUri": "GCS_OUTPUT_PATH",
"outputOptions": {
"mimeType": "OUTPUT_MIMETYPE",
"compressionQuality": COMPRESSION_QUALITY
},
"upscaleConfig": {
"upscaleFactor": "UPSCALE_FACTOR"
}
}
}
요청을 보내려면 다음 옵션 중 하나를 선택합니다.
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://aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/REGION/publishers/google/models/imagen-4.0-upscale-preview: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://aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/REGION/publishers/google/models/imagen-4.0-upscale-preview:predict" | Select-Object -Expand Content
{
"predictions": [
{
"mimeType": "image/png",
"bytesBase64Encoded": "BASE64_IMG_BYTES"
}
]
}
다음 단계
Imagen 및 Vertex AI의 기타 생성형 AI 제품 관련 문서 읽기:
- Vertex AI에서 Imagen 3 시작을 위한 개발자 가이드
- 크리에이터를 위해 제작된 새로운 생성형 미디어 모델 및 도구
- Gemini의 새로운 기능: Imagen 3의 커스텀 젬 및 향상된 이미지 생성
- Google DeepMind: Imagen 3 - 최고 품질의 텍스트 이미지 변환 모델