AutoML Edge 모델 내보내기

이 페이지에서는 Vertex AI를 사용하여 이미지 및 동영상 AutoML Edge 모델을 Cloud Storage로 내보내는 방법을 설명합니다.

테이블 형식 모델을 내보내는 방법에 대한 자세한 내용은 AutoML 테이블 형식 모델 내보내기를 참조하세요.

소개

AutoML Edge 모델을 학습한 후에는 용도에 따라 모델을 다른 형식으로 내보낼 수 있습니다. 내보낸 모델 파일은 Cloud Storage 버킷에 저장되며 선택한 환경의 예측에 사용될 수 있습니다.

Vertex AI의 Edge 모델을 사용하여 예측을 제공할 수 없습니다. 예측을 가져오려면 Edge 모델을 외부 기기에 배포해야 합니다.

모델을 내보냅니다.

다음 코드 샘플을 사용하여 AutoML Edge 모델을 식별하고 출력 파일 스토리지 위치를 지정한 후 모델 내보내기 요청을 보냅니다.

이미지

아래에서 목표에 대한 탭을 선택합니다.

분류

학습된 AutoML Edge 이미지 분류 모델은 다음 형식으로 내보낼 수 있습니다.

  • TF Lite - 모델을 TF Lite 패키지로 내보내 Edge 또는 휴대기기에서 모델을 실행합니다.
  • Edge TPU TF Lite - 모델을 TF Lite 패키지로 내보내어 Edge TPU 기기에서 모델을 실행합니다.
  • 컨테이너 - 모델을 TF 저장된 모델로 내보내 Docker 컨테이너에서 모델을 실행합니다.
  • Core ML - 모델을 .mlmodel 파일로 내보내 iOS 및 macOS 기기에서 모델을 실행합니다.
  • Tensorflow.js - 모델을 TensorFlow.js 패키지로 내보내 브라우저 및 Node.js에서 모델을 실행합니다.

아래에서 언어 또는 환경에 대한 탭을 선택하세요.

Console

  1. Google Cloud 콘솔의 Vertex AI 섹션에서 모델 페이지로 이동합니다.

    모델 페이지로 이동

  2. 내보내려는 AutoML Edge 모델의 버전 번호를 클릭하여 세부정보 페이지를 엽니다.
  3. 내보내기를 클릭합니다.
  4. 모델 내보내기 측면 창에서 Edge 모델 내보내기 출력을 저장할 Cloud Storage의 위치를 지정합니다.
  5. 내보내기를 클릭합니다.
  6. 완료를 클릭하여 모델 내보내기 측면 창을 닫습니다.

REST

요청 데이터를 사용하기 전에 다음을 바꿉니다.

  • LOCATION: 프로젝트의 위치입니다.
  • PROJECT: 프로젝트 ID
  • MODEL_ID: 내보내는 학습된 AutoML Edge 모델의 ID 번호입니다.
  • EXPORT_FORMAT: 내보내는 Edge 모델의 유형입니다. 이 목표의 옵션은 다음과 같습니다.
    • tflite(TF Lite) - 모델을 TF Lite 패키지로 내보내고 에지 또는 휴대기기에서 모델을 실행합니다.
    • edgetpu-tflite(Edge TPU TF Lite) - 모델을 TF Lite 패키지로 내보내고 Edge TPU 기기에서 모델을 실행합니다.
    • tf-saved-model(컨테이너) - 모델을 TF 저장된 모델로 내보내 Docker 컨테이너에서 모델을 실행합니다.
    • core-ml(Core ML) - .mlmodel 파일을 내보내 iOS 및 macOS 기기에서 모델을 실행합니다.
    • tf-js (Tensorflow.js) - 모델을 TensorFlow.js 패키지로 내보내 브라우저 및 Node.js에서 모델을 실행합니다.
  • OUTPUT_BUCKET: Edge 모델 파일을 저장할 Cloud Storage 버킷 디렉터리의 경로입니다.
  • HTTP 메서드 및 URL:

    POST https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT/locations/LOCATION/models/MODEL_ID:export

    JSON 요청 본문:

    {
      "outputConfig": {
        "exportFormatId": "EXPORT_FORMAT",
        "artifactDestination": {
          "outputUriPrefix": "gs://OUTPUT_BUCKET/"
        }
      }
    }
    

    요청을 보내려면 다음 옵션 중 하나를 선택합니다.

    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://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT/locations/LOCATION/models/MODEL_ID:export"

    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://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT/locations/LOCATION/models/MODEL_ID:export" | Select-Object -Expand Content

    응답에는 사양 및 OPERATION_ID에 대한 정보가 포함됩니다.

    내보내기 작업의 상태를 가져오면 작업이 완료되었는지 확인할 수 있습니다.

Java

이 샘플을 사용해 보기 전에 Vertex AI 빠른 시작: 클라이언트 라이브러리 사용Java 설정 안내를 따르세요. 자세한 내용은 Vertex AI Java API 참고 문서를 참조하세요.

Vertex AI에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.


import com.google.api.gax.longrunning.OperationFuture;
import com.google.cloud.aiplatform.v1.ExportModelOperationMetadata;
import com.google.cloud.aiplatform.v1.ExportModelRequest;
import com.google.cloud.aiplatform.v1.ExportModelResponse;
import com.google.cloud.aiplatform.v1.GcsDestination;
import com.google.cloud.aiplatform.v1.ModelName;
import com.google.cloud.aiplatform.v1.ModelServiceClient;
import com.google.cloud.aiplatform.v1.ModelServiceSettings;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public class ExportModelSample {

  public static void main(String[] args)
      throws IOException, InterruptedException, ExecutionException, TimeoutException {
    // TODO(developer): Replace these variables before running the sample.
    String project = "YOUR_PROJECT_ID";
    String modelId = "YOUR_MODEL_ID";
    String gcsDestinationOutputUriPrefix = "gs://YOUR_GCS_SOURCE_BUCKET/path_to_your_destination/";
    String exportFormat = "YOUR_EXPORT_FORMAT";
    exportModelSample(project, modelId, gcsDestinationOutputUriPrefix, exportFormat);
  }

  static void exportModelSample(
      String project, String modelId, String gcsDestinationOutputUriPrefix, String exportFormat)
      throws IOException, InterruptedException, ExecutionException, TimeoutException {
    ModelServiceSettings modelServiceSettings =
        ModelServiceSettings.newBuilder()
            .setEndpoint("us-central1-aiplatform.googleapis.com:443")
            .build();

    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (ModelServiceClient modelServiceClient = ModelServiceClient.create(modelServiceSettings)) {
      String location = "us-central1";
      GcsDestination.Builder gcsDestination = GcsDestination.newBuilder();
      gcsDestination.setOutputUriPrefix(gcsDestinationOutputUriPrefix);

      ModelName modelName = ModelName.of(project, location, modelId);
      ExportModelRequest.OutputConfig outputConfig =
          ExportModelRequest.OutputConfig.newBuilder()
              .setExportFormatId(exportFormat)
              .setArtifactDestination(gcsDestination)
              .build();

      OperationFuture<ExportModelResponse, ExportModelOperationMetadata> exportModelResponseFuture =
          modelServiceClient.exportModelAsync(modelName, outputConfig);
      System.out.format(
          "Operation name: %s\n", exportModelResponseFuture.getInitialFuture().get().getName());
      System.out.println("Waiting for operation to finish...");
      ExportModelResponse exportModelResponse =
          exportModelResponseFuture.get(300, TimeUnit.SECONDS);

      System.out.format("Export Model Response: %s\n", exportModelResponse);
    }
  }
}

Node.js

이 샘플을 사용해 보기 전에 Vertex AI 빠른 시작: 클라이언트 라이브러리 사용Node.js 설정 안내를 따르세요. 자세한 내용은 Vertex AI Node.js API 참고 문서를 참조하세요.

Vertex AI에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

/**
 * TODO(developer): Uncomment these variables before running the sample.\
   (Not necessary if passing values as arguments)
 */

// const modelId = 'YOUR_MODEL_ID';
// const gcsDestinationOutputUriPrefix ='YOUR_GCS_DEST_OUTPUT_URI_PREFIX';
//    eg. "gs://<your-gcs-bucket>/destination_path"
// const exportFormat = 'YOUR_EXPORT_FORMAT';
// const project = 'YOUR_PROJECT_ID';
// const location = 'YOUR_PROJECT_LOCATION';

// Imports the Google Cloud Model Service Client library
const {ModelServiceClient} = require('@google-cloud/aiplatform');

// Specifies the location of the api endpoint
const clientOptions = {
  apiEndpoint: 'us-central1-aiplatform.googleapis.com',
};

// Instantiates a client
const modelServiceClient = new ModelServiceClient(clientOptions);

async function exportModel() {
  // Configure the name resources
  const name = `projects/${project}/locations/${location}/models/${modelId}`;
  // Configure the outputConfig resources
  const outputConfig = {
    exportFormatId: exportFormat,
    gcsDestination: {
      outputUriPrefix: gcsDestinationOutputUriPrefix,
    },
  };
  const request = {
    name,
    outputConfig,
  };

  // Export Model request
  const [response] = await modelServiceClient.exportModel(request);
  console.log(`Long running operation : ${response.name}`);

  // Wait for operation to complete
  await response.promise();
  const result = response.result;

  console.log(`Export model response : ${JSON.stringify(result)}`);
}
exportModel();

Python

Python을 설치하거나 업데이트하는 방법은 Python용 Vertex AI SDK 설치를 참조하세요. 자세한 내용은 Python API 참고 문서를 참조하세요.

from google.cloud import aiplatform

def export_model_sample(
    project: str,
    model_id: str,
    gcs_destination_output_uri_prefix: str,
    location: str = "us-central1",
    api_endpoint: str = "us-central1-aiplatform.googleapis.com",
    timeout: int = 300,
):
    # The AI Platform services require regional API endpoints.
    client_options = {"api_endpoint": api_endpoint}
    # Initialize client that will be used to create and send requests.
    # This client only needs to be created once, and can be reused for multiple requests.
    client = aiplatform.gapic.ModelServiceClient(client_options=client_options)
    output_config = {
        "artifact_destination": {
            "output_uri_prefix": gcs_destination_output_uri_prefix
        },
        # For information about export formats: https://cloud.google.com/ai-platform-unified/docs/export/export-edge-model#aiplatform_export_model_sample-drest
        "export_format_id": "tf-saved-model",
    }
    name = client.model_path(project=project, location=location, model=model_id)
    response = client.export_model(name=name, output_config=output_config)
    print("Long running operation:", response.operation.name)
    print("output_info:", response.metadata.output_info)
    export_model_response = response.result(timeout=timeout)
    print("export_model_response:", export_model_response)

분류

학습된 AutoML Edge 이미지 분류 모델은 다음 형식으로 내보낼 수 있습니다.

  • TF Lite - 모델을 TF Lite 패키지로 내보내 Edge 또는 휴대기기에서 모델을 실행합니다.
  • Edge TPU TF Lite - 모델을 TF Lite 패키지로 내보내어 Edge TPU 기기에서 모델을 실행합니다.
  • 컨테이너 - 모델을 TF 저장된 모델로 내보내 Docker 컨테이너에서 모델을 실행합니다.
  • Core ML - 모델을 .mlmodel 파일로 내보내 iOS 및 macOS 기기에서 모델을 실행합니다.
  • Tensorflow.js - 모델을 TensorFlow.js 패키지로 내보내 브라우저 및 Node.js에서 모델을 실행합니다.

아래에서 언어 또는 환경에 대한 탭을 선택하세요.

Console

  1. Google Cloud 콘솔의 Vertex AI 섹션에서 모델 페이지로 이동합니다.

    모델 페이지로 이동

  2. 내보내려는 AutoML Edge 모델의 버전 번호를 클릭하여 세부정보 페이지를 엽니다.
  3. 내보내기를 클릭합니다.
  4. 모델 내보내기 측면 창에서 Edge 모델 내보내기 출력을 저장할 Cloud Storage의 위치를 지정합니다.
  5. 내보내기를 클릭합니다.
  6. 완료를 클릭하여 모델 내보내기 측면 창을 닫습니다.

REST

요청 데이터를 사용하기 전에 다음을 바꿉니다.

  • LOCATION: 프로젝트의 위치입니다.
  • PROJECT: 프로젝트 ID
  • MODEL_ID: 내보내는 학습된 AutoML Edge 모델의 ID 번호입니다.
  • EXPORT_FORMAT: 내보내는 Edge 모델의 유형입니다. 이 목표의 옵션은 다음과 같습니다.
    • tflite(TF Lite) - 모델을 TF Lite 패키지로 내보내고 에지 또는 휴대기기에서 모델을 실행합니다.
    • edgetpu-tflite(Edge TPU TF Lite) - 모델을 TF Lite 패키지로 내보내고 Edge TPU 기기에서 모델을 실행합니다.
    • tf-saved-model(컨테이너) - 모델을 TF 저장된 모델로 내보내 Docker 컨테이너에서 모델을 실행합니다.
    • core-ml(Core ML) - .mlmodel 파일을 내보내 iOS 및 macOS 기기에서 모델을 실행합니다.
    • tf-js (Tensorflow.js) - 모델을 TensorFlow.js 패키지로 내보내 브라우저 및 Node.js에서 모델을 실행합니다.
  • OUTPUT_BUCKET: Edge 모델 파일을 저장할 Cloud Storage 버킷 디렉터리의 경로입니다.
  • HTTP 메서드 및 URL:

    POST https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT/locations/LOCATION/models/MODEL_ID:export

    JSON 요청 본문:

    {
      "outputConfig": {
        "exportFormatId": "EXPORT_FORMAT",
        "artifactDestination": {
          "outputUriPrefix": "gs://OUTPUT_BUCKET/"
        }
      }
    }
    

    요청을 보내려면 다음 옵션 중 하나를 선택합니다.

    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://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT/locations/LOCATION/models/MODEL_ID:export"

    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://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT/locations/LOCATION/models/MODEL_ID:export" | Select-Object -Expand Content

    응답에는 사양 및 OPERATION_ID에 대한 정보가 포함됩니다.

    내보내기 작업의 상태를 가져오면 작업이 완료되었는지 확인할 수 있습니다.

Java

이 샘플을 사용해 보기 전에 Vertex AI 빠른 시작: 클라이언트 라이브러리 사용Java 설정 안내를 따르세요. 자세한 내용은 Vertex AI Java API 참고 문서를 참조하세요.

Vertex AI에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.


import com.google.api.gax.longrunning.OperationFuture;
import com.google.cloud.aiplatform.v1.ExportModelOperationMetadata;
import com.google.cloud.aiplatform.v1.ExportModelRequest;
import com.google.cloud.aiplatform.v1.ExportModelResponse;
import com.google.cloud.aiplatform.v1.GcsDestination;
import com.google.cloud.aiplatform.v1.ModelName;
import com.google.cloud.aiplatform.v1.ModelServiceClient;
import com.google.cloud.aiplatform.v1.ModelServiceSettings;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public class ExportModelSample {

  public static void main(String[] args)
      throws IOException, InterruptedException, ExecutionException, TimeoutException {
    // TODO(developer): Replace these variables before running the sample.
    String project = "YOUR_PROJECT_ID";
    String modelId = "YOUR_MODEL_ID";
    String gcsDestinationOutputUriPrefix = "gs://YOUR_GCS_SOURCE_BUCKET/path_to_your_destination/";
    String exportFormat = "YOUR_EXPORT_FORMAT";
    exportModelSample(project, modelId, gcsDestinationOutputUriPrefix, exportFormat);
  }

  static void exportModelSample(
      String project, String modelId, String gcsDestinationOutputUriPrefix, String exportFormat)
      throws IOException, InterruptedException, ExecutionException, TimeoutException {
    ModelServiceSettings modelServiceSettings =
        ModelServiceSettings.newBuilder()
            .setEndpoint("us-central1-aiplatform.googleapis.com:443")
            .build();

    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (ModelServiceClient modelServiceClient = ModelServiceClient.create(modelServiceSettings)) {
      String location = "us-central1";
      GcsDestination.Builder gcsDestination = GcsDestination.newBuilder();
      gcsDestination.setOutputUriPrefix(gcsDestinationOutputUriPrefix);

      ModelName modelName = ModelName.of(project, location, modelId);
      ExportModelRequest.OutputConfig outputConfig =
          ExportModelRequest.OutputConfig.newBuilder()
              .setExportFormatId(exportFormat)
              .setArtifactDestination(gcsDestination)
              .build();

      OperationFuture<ExportModelResponse, ExportModelOperationMetadata> exportModelResponseFuture =
          modelServiceClient.exportModelAsync(modelName, outputConfig);
      System.out.format(
          "Operation name: %s\n", exportModelResponseFuture.getInitialFuture().get().getName());
      System.out.println("Waiting for operation to finish...");
      ExportModelResponse exportModelResponse =
          exportModelResponseFuture.get(300, TimeUnit.SECONDS);

      System.out.format("Export Model Response: %s\n", exportModelResponse);
    }
  }
}

Node.js

이 샘플을 사용해 보기 전에 Vertex AI 빠른 시작: 클라이언트 라이브러리 사용Node.js 설정 안내를 따르세요. 자세한 내용은 Vertex AI Node.js API 참고 문서를 참조하세요.

Vertex AI에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

/**
 * TODO(developer): Uncomment these variables before running the sample.\
   (Not necessary if passing values as arguments)
 */

// const modelId = 'YOUR_MODEL_ID';
// const gcsDestinationOutputUriPrefix ='YOUR_GCS_DEST_OUTPUT_URI_PREFIX';
//    eg. "gs://<your-gcs-bucket>/destination_path"
// const exportFormat = 'YOUR_EXPORT_FORMAT';
// const project = 'YOUR_PROJECT_ID';
// const location = 'YOUR_PROJECT_LOCATION';

// Imports the Google Cloud Model Service Client library
const {ModelServiceClient} = require('@google-cloud/aiplatform');

// Specifies the location of the api endpoint
const clientOptions = {
  apiEndpoint: 'us-central1-aiplatform.googleapis.com',
};

// Instantiates a client
const modelServiceClient = new ModelServiceClient(clientOptions);

async function exportModel() {
  // Configure the name resources
  const name = `projects/${project}/locations/${location}/models/${modelId}`;
  // Configure the outputConfig resources
  const outputConfig = {
    exportFormatId: exportFormat,
    gcsDestination: {
      outputUriPrefix: gcsDestinationOutputUriPrefix,
    },
  };
  const request = {
    name,
    outputConfig,
  };

  // Export Model request
  const [response] = await modelServiceClient.exportModel(request);
  console.log(`Long running operation : ${response.name}`);

  // Wait for operation to complete
  await response.promise();
  const result = response.result;

  console.log(`Export model response : ${JSON.stringify(result)}`);
}
exportModel();

Python

Python을 설치하거나 업데이트하는 방법은 Python용 Vertex AI SDK 설치를 참조하세요. 자세한 내용은 Python API 참고 문서를 참조하세요.

from google.cloud import aiplatform

def export_model_sample(
    project: str,
    model_id: str,
    gcs_destination_output_uri_prefix: str,
    location: str = "us-central1",
    api_endpoint: str = "us-central1-aiplatform.googleapis.com",
    timeout: int = 300,
):
    # The AI Platform services require regional API endpoints.
    client_options = {"api_endpoint": api_endpoint}
    # Initialize client that will be used to create and send requests.
    # This client only needs to be created once, and can be reused for multiple requests.
    client = aiplatform.gapic.ModelServiceClient(client_options=client_options)
    output_config = {
        "artifact_destination": {
            "output_uri_prefix": gcs_destination_output_uri_prefix
        },
        # For information about export formats: https://cloud.google.com/ai-platform-unified/docs/export/export-edge-model#aiplatform_export_model_sample-drest
        "export_format_id": "tf-saved-model",
    }
    name = client.model_path(project=project, location=location, model=model_id)
    response = client.export_model(name=name, output_config=output_config)
    print("Long running operation:", response.operation.name)
    print("output_info:", response.metadata.output_info)
    export_model_response = response.result(timeout=timeout)
    print("export_model_response:", export_model_response)

객체 감지

학습된 AutoML Edge 이미지 객체 감지 모델은 다음 형식으로 내보낼 수 있습니다.

  • TF Lite - 모델을 TF Lite 패키지로 내보내 Edge 또는 휴대기기에서 모델을 실행합니다.
  • 컨테이너 - 모델을 TF 저장된 모델로 내보내 Docker 컨테이너에서 모델을 실행합니다.
  • Tensorflow.js - 모델을 TensorFlow.js 패키지로 내보내 브라우저 및 Node.js에서 모델을 실행합니다.

아래에서 언어 또는 환경에 대한 탭을 선택하세요.

Console

  1. Google Cloud 콘솔의 Vertex AI 섹션에서 모델 페이지로 이동합니다.

    모델 페이지로 이동

  2. 내보내려는 AutoML Edge 모델의 버전 번호를 클릭하여 세부정보 페이지를 엽니다.
  3. 배포 및 테스트 탭을 선택하여 사용 가능한 내보내기 형식을 봅니다.
  4. Edge에 최적화된 모델 사용 섹션에서 원하는 내보내기 모델 형식을 선택합니다.
  5. 모델 내보내기 측면 창에서 Edge 모델 내보내기 출력을 저장할 Cloud Storage의 위치를 지정합니다.
  6. 내보내기를 클릭합니다.
  7. 완료를 클릭하여 모델 내보내기 측면 창을 닫습니다.

REST

요청 데이터를 사용하기 전에 다음을 바꿉니다.

  • LOCATION: 프로젝트의 위치입니다.
  • PROJECT: 프로젝트 ID
  • MODEL_ID: 내보내는 학습된 AutoML Edge 모델의 ID 번호입니다.
  • EXPORT_FORMAT: 내보내는 Edge 모델의 유형입니다. 이 목표의 옵션은 다음과 같습니다.
    • tflite(TF Lite) - 모델을 TF Lite 패키지로 내보내고 에지 또는 휴대기기에서 모델을 실행합니다.
    • tf-saved-model(컨테이너) - 모델을 TF 저장된 모델로 내보내 Docker 컨테이너에서 모델을 실행합니다.
    • tf-js (Tensorflow.js) - 모델을 TensorFlow.js 패키지로 내보내 브라우저 및 Node.js에서 모델을 실행합니다.
  • OUTPUT_BUCKET: Edge 모델 파일을 저장할 Cloud Storage 버킷 디렉터리의 경로입니다.
  • HTTP 메서드 및 URL:

    POST https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT/locations/LOCATION/models/MODEL_ID:export

    JSON 요청 본문:

    {
      "outputConfig": {
        "exportFormatId": "EXPORT_FORMAT",
        "artifactDestination": {
          "outputUriPrefix": "gs://OUTPUT_BUCKET/"
        }
      }
    }
    

    요청을 보내려면 다음 옵션 중 하나를 선택합니다.

    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://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT/locations/LOCATION/models/MODEL_ID:export"

    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://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT/locations/LOCATION/models/MODEL_ID:export" | Select-Object -Expand Content

    응답에는 사양 및 OPERATION_ID에 대한 정보가 포함됩니다.

    내보내기 작업의 상태를 가져오면 작업이 완료되었는지 확인할 수 있습니다.

Java

이 샘플을 사용해 보기 전에 Vertex AI 빠른 시작: 클라이언트 라이브러리 사용Java 설정 안내를 따르세요. 자세한 내용은 Vertex AI Java API 참고 문서를 참조하세요.

Vertex AI에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.


import com.google.api.gax.longrunning.OperationFuture;
import com.google.cloud.aiplatform.v1.ExportModelOperationMetadata;
import com.google.cloud.aiplatform.v1.ExportModelRequest;
import com.google.cloud.aiplatform.v1.ExportModelResponse;
import com.google.cloud.aiplatform.v1.GcsDestination;
import com.google.cloud.aiplatform.v1.ModelName;
import com.google.cloud.aiplatform.v1.ModelServiceClient;
import com.google.cloud.aiplatform.v1.ModelServiceSettings;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public class ExportModelSample {

  public static void main(String[] args)
      throws IOException, InterruptedException, ExecutionException, TimeoutException {
    // TODO(developer): Replace these variables before running the sample.
    String project = "YOUR_PROJECT_ID";
    String modelId = "YOUR_MODEL_ID";
    String gcsDestinationOutputUriPrefix = "gs://YOUR_GCS_SOURCE_BUCKET/path_to_your_destination/";
    String exportFormat = "YOUR_EXPORT_FORMAT";
    exportModelSample(project, modelId, gcsDestinationOutputUriPrefix, exportFormat);
  }

  static void exportModelSample(
      String project, String modelId, String gcsDestinationOutputUriPrefix, String exportFormat)
      throws IOException, InterruptedException, ExecutionException, TimeoutException {
    ModelServiceSettings modelServiceSettings =
        ModelServiceSettings.newBuilder()
            .setEndpoint("us-central1-aiplatform.googleapis.com:443")
            .build();

    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (ModelServiceClient modelServiceClient = ModelServiceClient.create(modelServiceSettings)) {
      String location = "us-central1";
      GcsDestination.Builder gcsDestination = GcsDestination.newBuilder();
      gcsDestination.setOutputUriPrefix(gcsDestinationOutputUriPrefix);

      ModelName modelName = ModelName.of(project, location, modelId);
      ExportModelRequest.OutputConfig outputConfig =
          ExportModelRequest.OutputConfig.newBuilder()
              .setExportFormatId(exportFormat)
              .setArtifactDestination(gcsDestination)
              .build();

      OperationFuture<ExportModelResponse, ExportModelOperationMetadata> exportModelResponseFuture =
          modelServiceClient.exportModelAsync(modelName, outputConfig);
      System.out.format(
          "Operation name: %s\n", exportModelResponseFuture.getInitialFuture().get().getName());
      System.out.println("Waiting for operation to finish...");
      ExportModelResponse exportModelResponse =
          exportModelResponseFuture.get(300, TimeUnit.SECONDS);

      System.out.format("Export Model Response: %s\n", exportModelResponse);
    }
  }
}

Node.js

이 샘플을 사용해 보기 전에 Vertex AI 빠른 시작: 클라이언트 라이브러리 사용Node.js 설정 안내를 따르세요. 자세한 내용은 Vertex AI Node.js API 참고 문서를 참조하세요.

Vertex AI에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

/**
 * TODO(developer): Uncomment these variables before running the sample.\
   (Not necessary if passing values as arguments)
 */

// const modelId = 'YOUR_MODEL_ID';
// const gcsDestinationOutputUriPrefix ='YOUR_GCS_DEST_OUTPUT_URI_PREFIX';
//    eg. "gs://<your-gcs-bucket>/destination_path"
// const exportFormat = 'YOUR_EXPORT_FORMAT';
// const project = 'YOUR_PROJECT_ID';
// const location = 'YOUR_PROJECT_LOCATION';

// Imports the Google Cloud Model Service Client library
const {ModelServiceClient} = require('@google-cloud/aiplatform');

// Specifies the location of the api endpoint
const clientOptions = {
  apiEndpoint: 'us-central1-aiplatform.googleapis.com',
};

// Instantiates a client
const modelServiceClient = new ModelServiceClient(clientOptions);

async function exportModel() {
  // Configure the name resources
  const name = `projects/${project}/locations/${location}/models/${modelId}`;
  // Configure the outputConfig resources
  const outputConfig = {
    exportFormatId: exportFormat,
    gcsDestination: {
      outputUriPrefix: gcsDestinationOutputUriPrefix,
    },
  };
  const request = {
    name,
    outputConfig,
  };

  // Export Model request
  const [response] = await modelServiceClient.exportModel(request);
  console.log(`Long running operation : ${response.name}`);

  // Wait for operation to complete
  await response.promise();
  const result = response.result;

  console.log(`Export model response : ${JSON.stringify(result)}`);
}
exportModel();

Python

Python을 설치하거나 업데이트하는 방법은 Python용 Vertex AI SDK 설치를 참조하세요. 자세한 내용은 Python API 참고 문서를 참조하세요.

from google.cloud import aiplatform

def export_model_sample(
    project: str,
    model_id: str,
    gcs_destination_output_uri_prefix: str,
    location: str = "us-central1",
    api_endpoint: str = "us-central1-aiplatform.googleapis.com",
    timeout: int = 300,
):
    # The AI Platform services require regional API endpoints.
    client_options = {"api_endpoint": api_endpoint}
    # Initialize client that will be used to create and send requests.
    # This client only needs to be created once, and can be reused for multiple requests.
    client = aiplatform.gapic.ModelServiceClient(client_options=client_options)
    output_config = {
        "artifact_destination": {
            "output_uri_prefix": gcs_destination_output_uri_prefix
        },
        # For information about export formats: https://cloud.google.com/ai-platform-unified/docs/export/export-edge-model#aiplatform_export_model_sample-drest
        "export_format_id": "tf-saved-model",
    }
    name = client.model_path(project=project, location=location, model=model_id)
    response = client.export_model(name=name, output_config=output_config)
    print("Long running operation:", response.operation.name)
    print("output_info:", response.metadata.output_info)
    export_model_response = response.result(timeout=timeout)
    print("export_model_response:", export_model_response)

동영상

아래에서 목표에 대한 탭을 선택합니다.

동작 인식

학습된 AutoML Edge 동영상 동작 인식 모델은 저장된 모델 형식으로 내보낼 수 있습니다.

아래에서 언어 또는 환경에 대한 탭을 선택하세요.

Console

  1. Google Cloud 콘솔의 Vertex AI 섹션에서 모델 페이지로 이동합니다.

    모델 페이지로 이동

  2. 내보내려는 AutoML Edge 모델의 버전 번호를 클릭하여 세부정보 페이지를 엽니다.
  3. 내보내기를 클릭합니다.
  4. 모델 내보내기 측면 창에서 Edge 모델 내보내기 출력을 저장할 Cloud Storage의 위치를 지정합니다.
  5. 내보내기를 클릭합니다.
  6. 완료를 클릭하여 모델 내보내기 측면 창을 닫습니다.

REST

요청 데이터를 사용하기 전에 다음을 바꿉니다.

  • LOCATION: 모델이 저장된 리전입니다. 예를 들면 us-central1입니다.
  • MODEL_ID: 내보내는 학습된 AutoML Edge 모델의 ID 번호입니다.
  • EXPORT_FORMAT: 내보내는 Edge 모델의 유형입니다. 동영상 동작 인식의 경우 모델 옵션은 다음과 같습니다.
    • tf-saved-model(컨테이너) - 모델을 TF 저장된 모델로 내보내 Docker 컨테이너에서 모델을 실행합니다.
  • OUTPUT_BUCKET: Edge 모델 파일을 저장할 Cloud Storage 버킷 디렉터리의 경로입니다.
  • PROJECT_NUMBER: 프로젝트의 자동으로 생성된 프로젝트 번호

HTTP 메서드 및 URL:

POST https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION/models/MODEL_ID:export

JSON 요청 본문:

{
  "outputConfig": {
    "exportFormatId": "EXPORT_FORMAT",
    "artifactDestination": {
    "outputUriPrefix": "gs://OUTPUT_BUCKET/"
    }
  }
}

요청을 보내려면 다음 옵션 중 하나를 선택합니다.

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://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION/models/MODEL_ID:export"

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://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION/models/MODEL_ID:export" | Select-Object -Expand Content

응답에는 사양 및 OPERATION_ID에 대한 정보가 포함됩니다.

내보내기 작업의 상태를 가져오면 작업이 완료되었는지 확인할 수 있습니다.

Java

이 샘플을 사용해 보기 전에 Vertex AI 빠른 시작: 클라이언트 라이브러리 사용Java 설정 안내를 따르세요. 자세한 내용은 Vertex AI Java API 참고 문서를 참조하세요.

Vertex AI에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

import com.google.api.gax.longrunning.OperationFuture;
import com.google.cloud.aiplatform.v1.ExportModelOperationMetadata;
import com.google.cloud.aiplatform.v1.ExportModelRequest;
import com.google.cloud.aiplatform.v1.ExportModelResponse;
import com.google.cloud.aiplatform.v1.GcsDestination;
import com.google.cloud.aiplatform.v1.ModelName;
import com.google.cloud.aiplatform.v1.ModelServiceClient;
import com.google.cloud.aiplatform.v1.ModelServiceSettings;
import java.io.IOException;
import java.util.concurrent.ExecutionException;

public class ExportModelVideoActionRecognitionSample {

  public static void main(String[] args)
      throws IOException, ExecutionException, InterruptedException {
    // TODO(developer): Replace these variables before running the sample.
    String project = "PROJECT";
    String modelId = "MODEL_ID";
    String gcsDestinationOutputUriPrefix = "GCS_DESTINATION_OUTPUT_URI_PREFIX";
    String exportFormat = "EXPORT_FORMAT";
    exportModelVideoActionRecognitionSample(
        project, modelId, gcsDestinationOutputUriPrefix, exportFormat);
  }

  static void exportModelVideoActionRecognitionSample(
      String project, String modelId, String gcsDestinationOutputUriPrefix, String exportFormat)
      throws IOException, ExecutionException, InterruptedException {
    ModelServiceSettings settings =
        ModelServiceSettings.newBuilder()
            .setEndpoint("us-central1-aiplatform.googleapis.com:443")
            .build();
    String location = "us-central1";

    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (ModelServiceClient client = ModelServiceClient.create(settings)) {
      GcsDestination gcsDestination =
          GcsDestination.newBuilder().setOutputUriPrefix(gcsDestinationOutputUriPrefix).build();
      ExportModelRequest.OutputConfig outputConfig =
          ExportModelRequest.OutputConfig.newBuilder()
              .setArtifactDestination(gcsDestination)
              .setExportFormatId(exportFormat)
              .build();
      ModelName name = ModelName.of(project, location, modelId);
      OperationFuture<ExportModelResponse, ExportModelOperationMetadata> response =
          client.exportModelAsync(name, outputConfig);

      // You can use OperationFuture.getInitialFuture to get a future representing the initial
      // response to the request, which contains information while the operation is in progress.
      System.out.format("Operation name: %s\n", response.getInitialFuture().get().getName());

      // OperationFuture.get() will block until the operation is finished.
      ExportModelResponse exportModelResponse = response.get();
      System.out.format("exportModelResponse: %s\n", exportModelResponse);
    }
  }
}

Python

Python을 설치하거나 업데이트하는 방법은 Python용 Vertex AI SDK 설치를 참조하세요. 자세한 내용은 Python API 참고 문서를 참조하세요.

from google.cloud import aiplatform

def export_model_video_action_recognition_sample(
    project: str,
    model_id: str,
    gcs_destination_output_uri_prefix: str,
    export_format: str,
    location: str = "us-central1",
    api_endpoint: str = "us-central1-aiplatform.googleapis.com",
    timeout: int = 300,
):
    # The AI Platform services require regional API endpoints.
    client_options = {"api_endpoint": api_endpoint}
    # Initialize client that will be used to create and send requests.
    # This client only needs to be created once, and can be reused for multiple requests.
    client = aiplatform.gapic.ModelServiceClient(client_options=client_options)
    gcs_destination = {"output_uri_prefix": gcs_destination_output_uri_prefix}
    output_config = {
        "artifact_destination": gcs_destination,
        "export_format_id": export_format,
    }
    name = client.model_path(project=project, location=location, model=model_id)
    response = client.export_model(name=name, output_config=output_config)
    print("Long running operation:", response.operation.name)
    print("output_info:", response.metadata.output_info)
    export_model_response = response.result(timeout=timeout)
    print("export_model_response:", export_model_response)

분류

학습된 AutoML Edge 동영상 분류 모델을 저장된 모델 형식으로만 내보낼 수 있습니다.

아래에서 언어 또는 환경에 대한 탭을 선택하세요.

Console

  1. Google Cloud 콘솔의 Vertex AI 섹션에서 모델 페이지로 이동합니다.

    모델 페이지로 이동

  2. 내보내려는 AutoML Edge 모델의 버전 번호를 클릭하여 세부정보 페이지를 엽니다.
  3. 내보내기를 클릭합니다.
  4. 모델 내보내기 측면 창에서 Edge 모델 내보내기 출력을 저장할 Cloud Storage의 위치를 지정합니다.
  5. 내보내기를 클릭합니다.
  6. 완료를 클릭하여 모델 내보내기 측면 창을 닫습니다.

REST

요청 데이터를 사용하기 전에 다음을 바꿉니다.

  • LOCATION: 모델이 저장된 리전입니다. 예를 들면 us-central1입니다.
  • MODEL_ID: 내보내는 학습된 AutoML Edge 모델의 ID 번호입니다.
  • EXPORT_FORMAT: 내보내는 Edge 모델의 유형입니다. 동영상 분류의 경우 모델 옵션은 다음과 같습니다.
    • tf-saved-model(컨테이너) - 모델을 TF 저장된 모델로 내보내 Docker 컨테이너에서 모델을 실행합니다.
  • OUTPUT_BUCKET: Edge 모델 파일을 저장할 Cloud Storage 버킷 디렉터리의 경로입니다.
  • PROJECT_NUMBER: 프로젝트의 자동으로 생성된 프로젝트 번호

HTTP 메서드 및 URL:

POST https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION/models/MODEL_ID:export

JSON 요청 본문:

{
  "outputConfig": {
    "exportFormatId": "EXPORT_FORMAT",
    "artifactDestination": {
    "outputUriPrefix": "gs://OUTPUT_BUCKET/"
    }
  }
}

요청을 보내려면 다음 옵션 중 하나를 선택합니다.

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://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION/models/MODEL_ID:export"

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://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION/models/MODEL_ID:export" | Select-Object -Expand Content

응답에는 사양 및 OPERATION_ID에 대한 정보가 포함됩니다.

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION/models/MODEL_ID/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.aiplatform.v1.ExportModelOperationMetadata",
    "genericMetadata": {
      "createTime": "2020-10-12T20:53:40.130785Z",
      "updateTime": "2020-10-12T20:53:40.130785Z"
    },
    "outputInfo": {
      "artifactOutputUri": "gs://OUTPUT_BUCKET/model-MODEL_ID/EXPORT_FORMAT/YYYY-MM-DDThh:mm:ss.sssZ"
    }
  }
}

내보내기 작업의 상태를 가져오면 작업이 완료되었는지 확인할 수 있습니다.

객체 추적

학습된 AutoML Edge 동영상 객체 추적 모델을 다음 형식으로 내보낼 수 있습니다.

  • TF Lite - TensorFlow Lite 패키지로 모델을 내보내서 Edge 또는 휴대기기에서 실행합니다.
  • 컨테이너 - TensorFlow 저장된 모델로 내보내 Docker 컨테이너에서 모델을 실행합니다.

아래에서 언어 또는 환경에 대한 탭을 선택하세요.

Console

  1. Google Cloud 콘솔의 Vertex AI 섹션에서 모델 페이지로 이동합니다.

    모델 페이지로 이동

  2. 내보내려는 AutoML Edge 모델의 버전 번호를 클릭하여 세부정보 페이지를 엽니다.
  3. 내보내기를 클릭합니다.
  4. 모델 내보내기 측면 창에서 Edge 모델 내보내기 출력을 저장할 Cloud Storage의 위치를 지정합니다.
  5. 내보내기를 클릭합니다.
  6. 완료를 클릭하여 모델 내보내기 측면 창을 닫습니다.

REST

요청 데이터를 사용하기 전에 다음을 바꿉니다.

  • LOCATION: 모델이 저장된 리전입니다. 예를 들면 us-central1입니다.
  • MODEL_ID: 내보내는 학습된 AutoML Edge 모델의 ID 번호입니다.
  • EXPORT_FORMAT: 내보내는 Edge 모델의 유형입니다. 동영상 객체 추적 모델의 경우 옵션은 다음과 같습니다.
    • tflite(TF Lite) - 모델을 TF Lite 패키지로 내보내고 에지 또는 휴대기기에서 모델을 실행합니다.
    • edgetpu-tflite(Edge TPU TF Lite) - 모델을 TF Lite 패키지로 내보내고 Edge TPU 기기에서 모델을 실행합니다.
    • tf-saved-model(컨테이너) - 모델을 TF 저장된 모델로 내보내 Docker 컨테이너에서 모델을 실행합니다.
  • OUTPUT_BUCKET: Edge 모델 파일을 저장할 Cloud Storage 버킷 디렉터리의 경로입니다.
  • PROJECT_NUMBER: 프로젝트의 자동으로 생성된 프로젝트 번호

HTTP 메서드 및 URL:

POST https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION/models/MODEL_ID:export

JSON 요청 본문:

{
  "outputConfig": {
    "exportFormatId": "EXPORT_FORMAT",
    "artifactDestination": {
    "outputUriPrefix": "gs://OUTPUT_BUCKET/"
    }
  }
}

요청을 보내려면 다음 옵션 중 하나를 선택합니다.

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://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION/models/MODEL_ID:export"

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://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION/models/MODEL_ID:export" | Select-Object -Expand Content

응답에는 사양 및 OPERATION_ID에 대한 정보가 포함됩니다.

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION/models/MODEL_ID/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.aiplatform.v1.ExportModelOperationMetadata",
    "genericMetadata": {
      "createTime": "2020-10-12T20:53:40.130785Z",
      "updateTime": "2020-10-12T20:53:40.130785Z"
    },
    "outputInfo": {
      "artifactOutputUri": "gs://OUTPUT_BUCKET/model-MODEL_ID/EXPORT_FORMAT/YYYY-MM-DDThh:mm:ss.sssZ"
    }
  }
}

내보내기 작업의 상태를 가져오면 작업이 완료되었는지 확인할 수 있습니다.

작업 상태 가져오기

이미지

다음 코드를 사용하여 내보내기 작업 상태를 가져옵니다. 이 코드는 모든 목표에 동일합니다.

REST

요청 데이터를 사용하기 전에 다음을 바꿉니다.

  • LOCATION: 프로젝트의 위치입니다.
  • PROJECT: 프로젝트 ID
  • OPERATION_ID: 대상 작업의 ID입니다. 이 ID는 일반적으로 원래 요청에 대한 응답에 포함되어 있습니다.

HTTP 메서드 및 URL:

GET https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT/locations/LOCATION/operations/OPERATION_ID

요청을 보내려면 다음 옵션 중 하나를 선택합니다.

curl

다음 명령어를 실행합니다.

curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT/locations/LOCATION/operations/OPERATION_ID"

PowerShell

다음 명령어를 실행합니다.

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT/locations/LOCATION/operations/OPERATION_ID" | Select-Object -Expand Content
가져오기 작업이 완료되면 다음과 유사한 출력이 표시됩니다.
{
  "name": "projects/PROJECT/locations/LOCATION/models/MODEL_ID/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.aiplatform.v1.ExportModelOperationMetadata",
    "genericMetadata": {
      "createTime": "2020-10-12T20:53:40.130785Z",
      "updateTime": "2020-10-12T20:53:40.793983Z"
    },
    "outputInfo": {
      "artifactOutputUri": "gs://OUTPUT_BUCKET/model-MODEL_ID/EXPORT_FORMAT/YYYY-MM-DDThh:mm:ss.sssZ"
    }
  },
  "done": true,
  "response": {
    "@type": "type.googleapis.com/google.cloud.aiplatform.v1.ExportModelResponse"
  }
}

동영상

REST

요청 데이터를 사용하기 전에 다음을 바꿉니다.

  • PROJECT_NUMBER: 프로젝트의 자동으로 생성된 프로젝트 번호
  • LOCATION: 모델이 저장된 리전입니다. 예를 들면 us-central1입니다.
  • OPERATION_ID: 작업 ID입니다.

HTTP 메서드 및 URL:

GET https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT/locations/LOCATION/operations/OPERATION_ID

요청을 보내려면 다음 옵션 중 하나를 선택합니다.

curl

다음 명령어를 실행합니다.

curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT/locations/LOCATION/operations/OPERATION_ID"

PowerShell

다음 명령어를 실행합니다.

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT/locations/LOCATION/operations/OPERATION_ID" | Select-Object -Expand Content

다음과 비슷한 JSON 응답이 표시됩니다.

출력 파일

이미지

아래에서 모델 형식에 대한 탭을 선택하세요.

TF Lite

요청에서 지정한 OUTPUT_BUCKET은 출력 파일이 저장되는 위치를 결정합니다. 출력 파일이 저장되는 디렉터리 형식은 다음 형식을 따릅니다.

  • gs://OUTPUT_BUCKET/model-MODEL_ID/tflite/YYYY-MM-DDThh:mm:ss.sssZ/

파일:

  1. model.tflite: TensorFlow Lite와 함께 사용할 수 있는 모델 버전이 포함된 파일입니다.

Edge TPU

요청에서 지정한 OUTPUT_BUCKET은 출력 파일이 저장되는 위치를 결정합니다. 출력 파일이 저장되는 디렉터리 형식은 다음 형식을 따릅니다.

  • gs://OUTPUT_BUCKET/model-MODEL_ID/edgetpu-tflite/YYYY-MM-DDThh:mm:ss.sssZ/

파일:

  1. edgetpu_model.tflite: Edge TPU와 호환되도록 Edge TPU 컴파일러를 통해 전달되는 TensorFlow Lite 모델 버전이 포함된 파일입니다.

컨테이너

요청에서 지정한 OUTPUT_BUCKET은 출력 파일이 저장되는 위치를 결정합니다. 출력 파일이 저장되는 디렉터리 형식은 다음 형식을 따릅니다.

  • gs://OUTPUT_BUCKET/model-MODEL_ID/tf-saved-model/YYYY-MM-DDThh:mm:ss.sssZ/

파일:

  1. saved_model.pb: 그래프 정의와 모델 가중치가 포함된 프로토콜 버퍼 파일입니다.

Core ML

요청에서 지정한 OUTPUT_BUCKET은 출력 파일이 저장되는 위치를 결정합니다. 출력 파일이 저장되는 디렉터리 형식은 다음 형식을 따릅니다.

  • gs://OUTPUT_BUCKET/model-MODEL_ID/core-ml/YYYY-MM-DDThh:mm:ss.sssZ/

파일:

  1. dict.txt: 라벨 파일입니다. 라벨 파일 dict.txt의 각 행은 모델이 반환하는 예측의 라벨을 요청과 동일한 순서대로 나타냅니다.

    샘플 dict.txt

    roses
    daisy
    tulips
    dandelion
    sunflowers
    
  2. model.mlmodel: Core ML 모델을 지정하는 파일입니다.

Tensorflow.js

요청에서 지정한 OUTPUT_BUCKET은 출력 파일이 저장되는 위치를 결정합니다. 출력 파일이 저장되는 디렉터리 형식은 다음 형식을 따릅니다.

  • gs://OUTPUT_BUCKET/model-MODEL_ID/tf-js/YYYY-MM-DDThh:mm:ss.sssZ/

파일:

  1. dict.txt: 라벨 파일입니다. 라벨 파일 dict.txt의 각 행은 모델이 반환하는 예측의 라벨을 요청과 동일한 순서대로 나타냅니다.

    샘플 dict.txt

    roses
    daisy
    tulips
    dandelion
    sunflowers
    
  2. group1-shard1of3.bin: 바이너리 파일입니다.
  3. group1-shard2of3.bin: 바이너리 파일입니다.
  4. group1-shard3of3.bin: 바이너리 파일입니다.
  5. model.json: 모델의 JSON 파일 표현입니다.

    샘플 model.json(명확성을 위해 축약됨)

    {
      "format": "graph-model",
      "generatedBy": "2.4.0",
      "convertedBy": "TensorFlow.js Converter v1.7.0",
      "userDefinedMetadata": {
        "signature": {
          "inputs": {
            "image:0": {
              "name": "image:0",
              "dtype": "DT_FLOAT",
              "tensorShape": {
                "dim": [
                  {
                    "size": "1"
                  },
                  {
                    "size": "224"
                  },
                  {
                    "size": "224"
                  },
                  {
                    "size": "3"
                  }
                ]
              }
            }
          },
          "outputs": {
            "scores:0": {
              "name": "scores:0",
              "dtype": "DT_FLOAT",
              "tensorShape": {
                "dim": [
                  {
                    "size": "1"
                  },
                  {
                    "size": "5"
                  }
                ]
              }
            }
          }
        }
      },
      "modelTopology": {
        "node": [
          {
            "name": "image",
            "op": "Placeholder",
            "attr": {
              "dtype": {
                "type": "DT_FLOAT"
              },
              "shape": {
                "shape": {
                  "dim": [
                    {
                      "size": "1"
                    },
                    {
                      "size": "224"
                    },
                    {
                      "size": "224"
                    },
                    {
                      "size": "3"
                    }
                  ]
                }
              }
            }
          },
          {
            "name": "mnas_v4_a_1/feature_network/feature_extractor/Mean/reduction_indices",
            "op": "Const",
            "attr": {
              "value": {
                "tensor": {
                  "dtype": "DT_INT32",
                  "tensorShape": {
                    "dim": [
                      {
                        "size": "2"
                      }
                    ]
                  }
                }
              },
              "dtype": {
                "type": "DT_INT32"
              }
            }
          },
          ...
          {
            "name": "scores",
            "op": "Identity",
            "input": [
              "Softmax"
            ],
            "attr": {
              "T": {
                "type": "DT_FLOAT"
              }
            }
          }
        ],
        "library": {},
        "versions": {}
      },
      "weightsManifest": [
        {
          "paths": [
            "group1-shard1of3.bin",
            "group1-shard2of3.bin",
            "group1-shard3of3.bin"
          ],
          "weights": [
            {
              "name": "mnas_v4_a_1/feature_network/feature_extractor/Mean/reduction_indices",
              "shape": [
                2
              ],
              "dtype": "int32"
            },
            {
              "name": "mnas_v4_a/output/fc/tf_layer/kernel",
              "shape": [
                1280,
                5
              ],
              "dtype": "float32"
            },
            ...
            {
              "name": "mnas_v4_a_1/feature_network/lead_cell_17/op_0/conv2d_0/Conv2D_weights",
              "shape": [
                1,
                1,
                320,
                1280
              ],
              "dtype": "float32"
            },
            {
              "name": "mnas_v4_a_1/feature_network/cell_14/op_0/expand_0/Conv2D_bn_offset",
              "shape": [
                1152
              ],
              "dtype": "float32"
            }
          ]
        }
      ]
    }

동영상

아래에서 모델 형식에 대한 탭을 선택하세요.

TF Lite

요청에서 지정한 OUTPUT_BUCKET은 출력 파일이 저장되는 위치를 결정합니다. 출력 파일이 저장되는 디렉터리 형식은 다음 형식을 따릅니다.

  • gs://OUTPUT_BUCKET/model-MODEL_ID/tflite/YYYY-MM-DDThh:mm:ss.sssZ/

파일:

  1. model.tflite: TensorFlow Lite와 함께 사용할 수 있는 모델 버전이 포함된 파일입니다.
  2. frozen_inference_graph.pb: 그래프 정의와 모델 가중치가 포함된 직렬화된 프로토콜 버퍼 파일입니다.
  3. label_map.pbtxt: 사용된 각 라벨을 정수 값에 매핑하는 라벨 맵 파일입니다.

Edge TPU

요청에서 지정한 OUTPUT_BUCKET은 출력 파일이 저장되는 위치를 결정합니다. 출력 파일이 저장되는 디렉터리 형식은 다음 형식을 따릅니다.

  • gs://OUTPUT_BUCKET/model-MODEL_ID/edgetpu-tflite/YYYY-MM-DDThh:mm:ss.sssZ/

파일:

  1. edgetpu_model.tflite: Edge TPU와 호환되도록 Edge TPU 컴파일러를 통해 전달되는 TensorFlow Lite 모델 버전이 포함된 파일입니다.
  2. label_map.pbtxt: 사용된 각 라벨을 정수 값에 매핑하는 라벨 맵 파일입니다.

컨테이너

요청에서 지정한 OUTPUT_BUCKET은 출력 파일이 저장되는 위치를 결정합니다. 출력 파일이 저장되는 디렉터리 형식은 다음 형식을 따릅니다.

  • gs://OUTPUT_BUCKET/model-MODEL_ID/tf-saved-model/YYYY-MM-DDThh:mm:ss.sssZ/

파일:

  1. frozen_inference_graph.pb: 그래프 정의와 모델 가중치가 포함된 직렬화된 프로토콜 버퍼 파일입니다.
  2. label_map.pbtxt: 사용된 각 라벨을 정수 값에 매핑하는 라벨 맵 파일입니다.
  3. saved_model/saved_model.pb: 이 파일은 실제 TensorFlow 프로그램 또는 모델, 그리고 이름이 지정된 서명 집합을 저장합니다. 각각의 서명에서 텐서 입력을 허용하고 텐서 출력을 생성하는 함수를 식별합니다.
  4. saved_model/variables/: 변수 디렉터리에는 표준 학습 체크포인트가 포함됩니다.