모델 학습, 데이터 세트로 파일 가져오기, 모델 삭제 등 요청되는 작업 중 다수는 실행에 오랜 시간이 소요됩니다. 이러한 유형의 요청은 작업 상태를 가져오는 데 사용할 수 있는 작업 ID와 함께 JSON을 반환합니다.
예를 들어 모델 학습 요청은 다음 JSON을 반환합니다.
{ "name": "projects/PROJECT_ID/locations/us-central1/operations/IOD3074819451447672458", "metadata": { "@type": "type.googleapis.com/google.cloud.automl.v1.OperationMetadata", "createTime": "2019-07-26T21:10:18.338846Z", "updateTime": "2019-07-26T21:10:18.338846Z", "createModelDetails": {} } }
이 경우 작업 ID는 IOD3074819451447672458
입니다. 다음 샘플은 이 ID로 이 작업의 상태를 가져오는 방법을 보여줍니다.
REST
요청 데이터를 사용하기 전에 다음을 바꿉니다.
- project-id: GCP 프로젝트 ID입니다.
- operation-id: 작업의 ID입니다. ID는 작업 이름의 마지막 요소입니다. 예를 들면 다음과 같습니다.
- 작업 이름:
projects/project-id/locations/location-id/operations/IOD5281059901324392598
- 작업 ID:
IOD5281059901324392598
- 작업 이름:
HTTP 메서드 및 URL:
GET https://automl.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/operations/OPERATION_ID
요청을 보내려면 다음 옵션 중 하나를 선택합니다.
curl
다음 명령어를 실행합니다.
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "x-goog-user-project: project-id" \
"https://automl.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/operations/OPERATION_ID"
PowerShell
다음 명령어를 실행합니다.
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred"; "x-goog-user-project" = "project-id" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://automl.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/operations/OPERATION_ID" | Select-Object -Expand Content
{ "name": "projects/PROJECT_ID/locations/us-central1/operations/OPERATION_ID", "metadata": { "@type": "type.googleapis.com/google.cloud.automl.v1.OperationMetadata", "createTime": "2018-10-29T15:56:29.176485Z", "updateTime": "2018-10-29T16:10:41.326614Z", "importDataDetails": {} }, "done": true, "response": { "@type": "type.googleapis.com/google.protobuf.Empty" } }
모델 만들기 작업이 완료되면 다음과 유사한 출력이 표시됩니다.
{ "name": "projects/PROJECT_ID/locations/us-central1/operations/OPERATION_ID", "metadata": { "@type": "type.googleapis.com/google.cloud.automl.v1.OperationMetadata", "createTime": "2019-07-22T18:35:06.881193Z", "updateTime": "2019-07-22T19:58:44.972235Z", "createModelDetails": {} }, "done": true, "response": { "@type": "type.googleapis.com/google.cloud.automl.v1.Model", "name": "projects/PROJECT_ID/locations/us-central1/models/MODEL_ID" } }
Go
이 샘플을 사용해 보기 전에 클라이언트 라이브러리 페이지에서 언어 설정 안내를 따르세요.
Java
이 샘플을 사용해 보기 전에 클라이언트 라이브러리 페이지에서 언어 설정 안내를 따르세요.
Node.js
이 샘플을 사용해 보기 전에 클라이언트 라이브러리 페이지에서 언어 설정 안내를 따르세요.
Python
이 샘플을 사용해 보기 전에 클라이언트 라이브러리 페이지에서 언어 설정 안내를 따르세요.
추가 언어
C#: 클라이언트 라이브러리 페이지의 C# 설정 안내를 따른 다음 .NET용 AutoML Vision 객체 감지 참고 문서를 참조하세요.
PHP: 클라이언트 라이브러리 페이지의 PHP 설정 안내를 따른 다음 PHP용 AutoML Vision 객체 감지 참고 문서를 참조하세요.
Ruby: 클라이언트 라이브러리 페이지의 Ruby 설정 안내를 따른 다음 Ruby용 AutoML Vision 객체 감지 참고 문서를 참조하세요.