모델 관리

모델은 사용자가 제공한 준비된 데이터 세트를 사용하여 학습됩니다. AutoML Video Intelligence 객체 추적은 데이터 세트의 항목을 사용하여 모델의 성능을 학습, 테스트, 평가합니다. 그런 다음 결과를 검토하고 필요하면 학습 데이터 세트를 조정하며 향상된 데이터 세트를 사용하여 새 모델을 학습시켜야 합니다.

모델 학습이 완료되기까지 몇 시간 정도 걸릴 수 있습니다. AutoML API를 사용하면 학습의 상태를 확인할 수 있습니다.

학습을 시작할 때마다 AutoML Video Intelligence Object Tracking이 새 모델을 생성하므로 프로젝트에 수많은 모델이 포함될 수 있습니다. 프로젝트에 포함된 모델의 목록을 가져오고 더 이상 필요 없는 모델을 삭제할 수 있습니다.

모델의 최대 수명은 2년입니다. 그 기간이 지난 후에도 객체 추적을 계속하려면 새 모델을 만들고 학습시켜야 합니다.

curl 또는 PowerShell 사용

이 주제에서 curl(또는 PowerShell) 샘플을 보다 편리하게 실행하려면 다음 환경 변수를 설정합니다. project-id를 Google Cloud 프로젝트의 이름으로 바꿉니다.

export PROJECT_ID="project-id"

모델 학습

라벨이 지정된 학습 항목이 다수 포함된 데이터 세트가 있으면 모델을 만들고 학습시킬 수 있습니다.

웹 UI

  1. AutoML Video Object Tracking UI 를 열고 데이터 세트 페이지로 이동합니다.

    Google Cloud Console의 데이터세트 페이지
  2. 모델을 학습시키는 데 사용할 데이터 세트를 선택합니다.

    선택한 데이터 세트의 이름이 제목 표시줄에 나타나고 페이지에는 데이터 세트에 있는 개별 항목이 라벨과 함께 나열됩니다.

    두 개의 동영상이 표시된 동영상 탭
  3. 데이터 세트 검토가 끝났으면 제목 표시줄 바로 아래에 있는 학습하기 탭을 클릭합니다.

    학습 페이지에는 데이터 세트에 대한 기본 분석이 제공되며 데이터 세트가 학습에 적합한지 여부를 알려 줍니다. AutoML Video Object Tracking에서 변경을 제안하면 동영상 페이지로 돌아가서 항목이나 라벨을 추가하는 것이 좋습니다.

  4. 데이터세트가 준비되면 학습 시작을 클릭하여 새 모델을 만들거나 새 모델 학습을 클릭하여 추가 모델을 만듭니다.

REST

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

  • dataset-id: 대상 데이터 세트의 이름입니다. 예를 들어 my_dataset_01 표시 이름입니다.
  • model-name: 모델에 선택한 이름으로 바꿉니다.
  • 참고:
    • project-number: 프로젝트 수입니다.
    • location-id: 주석이 있어야 하는 Cloud 리전입니다. 지원되는 클라우드 리전은 us-east1, us-west1, europe-west1, asia-east1입니다. 리전을 지정하지 않으면 동영상 파일 위치를 기준으로 리전이 결정됩니다.

HTTP 메서드 및 URL:

POST https://automl.googleapis.com/v1beta1/projects/project-number/locations/location-id/models

JSON 요청 본문:

{
  "datasetId": "dataset-id",
  "displayName": "model-name",
  "videoObjectTrackingModelMetadata": {},
}

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

curl

요청 본문을 request.json 파일에 저장하고 다음 명령어를 실행합니다.

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "x-goog-user-project: project-number" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://automl.googleapis.com/v1beta1/projects/project-number/locations/location-id/models"

PowerShell

요청 본문을 request.json 파일에 저장하고 다음 명령어를 실행합니다.

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred"; "x-goog-user-project" = "project-number" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://automl.googleapis.com/v1beta1/projects/project-number/locations/location-id/models" | Select-Object -Expand Content
모델 학습 작업의 작업 ID를 받아야 합니다. 위의 예시는 모델 학습 작업 ID VOT1741767155885539328가 포함된 응답을 보여줍니다.

Java

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

import com.google.api.gax.longrunning.OperationFuture;
import com.google.cloud.automl.v1beta1.AutoMlClient;
import com.google.cloud.automl.v1beta1.LocationName;
import com.google.cloud.automl.v1beta1.Model;
import com.google.cloud.automl.v1beta1.OperationMetadata;
import com.google.cloud.automl.v1beta1.VideoObjectTrackingModelMetadata;
import java.io.IOException;
import java.util.concurrent.ExecutionException;

class VideoObjectTrackingCreateModel {

  public static void main(String[] args)
      throws IOException, ExecutionException, InterruptedException {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "YOUR_PROJECT_ID";
    String datasetId = "YOUR_DATASET_ID";
    String displayName = "YOUR_DATASET_NAME";
    createModel(projectId, datasetId, displayName);
  }

  // Create a model
  static void createModel(String projectId, String datasetId, String displayName)
      throws IOException, ExecutionException, InterruptedException {
    // 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 (AutoMlClient client = AutoMlClient.create()) {
      // A resource that represents Google Cloud Platform location.
      LocationName projectLocation = LocationName.of(projectId, "us-central1");
      // Set model metadata.
      VideoObjectTrackingModelMetadata metadata =
          VideoObjectTrackingModelMetadata.newBuilder().build();
      Model model =
          Model.newBuilder()
              .setDisplayName(displayName)
              .setDatasetId(datasetId)
              .setVideoObjectTrackingModelMetadata(metadata)
              .build();

      // Create a model with the model metadata in the region.
      OperationFuture<Model, OperationMetadata> future =
          client.createModelAsync(projectLocation, model);
      // OperationFuture.get() will block until the model is created, which may take several hours.
      // 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("Training operation name: %s%n", future.getInitialFuture().get().getName());
      System.out.println("Training started...");
    }
  }
}

Node.js

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

/**
 * TODO(developer): Uncomment these variables before running the sample.
 */
// const projectId = 'YOUR_PROJECT_ID';
// const location = 'us-central1';
// const dataset_id = 'YOUR_DATASET_ID';
// const displayName = 'YOUR_DISPLAY_NAME';

// Imports the Google Cloud AutoML library
const {AutoMlClient} = require('@google-cloud/automl').v1beta1;

// Instantiates a client
const client = new AutoMlClient();

async function createModel() {
  // Construct request
  const request = {
    parent: client.locationPath(projectId, location),
    model: {
      displayName: displayName,
      datasetId: datasetId,
      videoObjectTrackingModelMetadata: {},
    },
  };

  // Don't wait for the LRO
  const [operation] = await client.createModel(request);
  console.log(`Training started... ${operation}`);
  console.log(`Training operation name: ${operation.name}`);
}

createModel();

Python

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

from google.cloud import automl_v1beta1 as automl

def create_model(
    project_id="YOUR_PROJECT_ID",
    dataset_id="YOUR_DATASET_ID",
    display_name="your_models_display_name",
):
    """Create a automl video classification model."""
    client = automl.AutoMlClient()

    # A resource that represents Google Cloud Platform loacation.
    project_location = f"projects/{project_id}/locations/us-central1"
    # Leave model unset to use the default base model provided by Google
    metadata = automl.VideoObjectTrackingModelMetadata()
    model = automl.Model(
        display_name=display_name,
        dataset_id=dataset_id,
        video_object_tracking_model_metadata=metadata,
    )

    # Create a model with the model metadata in the region.
    response = client.create_model(parent=project_location, model=model)

    print(f"Training operation name: {response.operation.name}")
    print("Training started...")

작업 상태 가져오기

태스크를 시작할 때 작업 ID를 사용하여 응답에서 항목을 데이터 세트로 가져오기 또는 모델의 학습과 같은 장기 실행 태스크 상태를 확인할 수 있습니다.

REST

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

  • operation-id: 작업을 시작할 때 요청으로 생성되고 응답으로 제공된 장기 실행 작업의 ID로 예를 들면 VOT12345....입니다.
  • 참고:
    • project-number: 프로젝트 수입니다.
    • location-id: 주석이 있어야 하는 Cloud 리전입니다. 지원되는 클라우드 리전은 us-east1, us-west1, europe-west1, asia-east1입니다. 리전을 지정하지 않으면 동영상 파일 위치를 기준으로 리전이 결정됩니다.

HTTP 메서드 및 URL:

GET https://automl.googleapis.com/v1beta1/projects/project-number/locations/location-id/operations/operation-id

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

curl

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

curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "x-goog-user-project: project-number" \
"https://automl.googleapis.com/v1beta1/projects/project-number/locations/location-id/operations/operation-id"

PowerShell

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

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred"; "x-goog-user-project" = "project-number" }

Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://automl.googleapis.com/v1beta1/projects/project-number/locations/location-id/operations/operation-id" | Select-Object -Expand Content
가져오기 작업을 완료하는 데 다소 시간이 걸릴 수 있습니다. 가져오기 작업이 완료되면 위의 예시와 같이 작업 상태가 오류없이 done: true로 표시됩니다.
  • operation-name: AutoML Video Intelligence 객체 추적 API에서 반환하는 작업의 이름입니다. 작업 이름은 projects/project-number/locations/location-id/operations/operation-id 형식입니다.

Java

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

import com.google.cloud.automl.v1beta1.AutoMlClient;
import com.google.longrunning.Operation;
import java.io.IOException;

class GetOperationStatus {

  static void getOperationStatus() throws IOException {
    // TODO(developer): Replace these variables before running the sample.
    String operationFullId = "projects/[projectId]/locations/us-central1/operations/[operationId]";
    getOperationStatus(operationFullId);
  }

  // Get the status of an operation
  static void getOperationStatus(String operationFullId) throws IOException {
    // 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 (AutoMlClient client = AutoMlClient.create()) {
      // Get the latest state of a long-running operation.
      Operation operation = client.getOperationsClient().getOperation(operationFullId);

      // Display operation details.
      System.out.println("Operation details:");
      System.out.format("\tName: %s%n", operation.getName());
      System.out.format("\tMetadata Type Url: %s%n", operation.getMetadata().getTypeUrl());
      System.out.format("\tDone: %s%n", operation.getDone());
      if (operation.hasResponse()) {
        System.out.format("\tResponse Type Url: %s%n", operation.getResponse().getTypeUrl());
      }
      if (operation.hasError()) {
        System.out.println("\tResponse:");
        System.out.format("\t\tError code: %s%n", operation.getError().getCode());
        System.out.format("\t\tError message: %s%n", operation.getError().getMessage());
      }
    }
  }
}

Node.js

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

/**
 * TODO(developer): Uncomment these variables before running the sample.
 */
// const projectId = 'YOUR_PROJECT_ID';
// const location = 'us-central1';
// const operationId = 'YOUR_OPERATION_ID';

// Imports the Google Cloud AutoML library
const {AutoMlClient} = require('@google-cloud/automl').v1beta1;

// Instantiates a client
const client = new AutoMlClient();

async function getOperationStatus() {
  // Construct request
  const request = {
    name: `projects/${projectId}/locations/${location}/operations/${operationId}`,
  };

  const [response] = await client.operationsClient.getOperation(request);

  console.log(`Name: ${response.name}`);
  console.log('Operation details:');
  console.log(response);
}

getOperationStatus();

Python

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

from google.cloud import automl_v1beta1 as automl

def get_operation_status(
    operation_full_id="projects/YOUR_PROJECT_ID/locations/us-central1/"
    "operations/YOUR_OPERATION_ID",
):
    """Get operation status."""
    client = automl.AutoMlClient()

    # Get the latest state of a long-running operation.
    response = client._transport.operations_client.get_operation(operation_full_id)

    print(f"Name: {response.name}")
    print("Operation details:")
    print(response)

작업 취소

작업 ID를 사용하여 가져오기, 학습, 일괄 예측 작업을 취소할 수 있습니다.

REST

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

  • operation id: 작업을 시작할 때 응답에 제공되는 것으로 예를 들면 VOT123…입니다.
  • 참고:
    • project-id: GCP 프로젝트 ID
    • location-id: 주석이 있어야 하는 Cloud 리전입니다. 지원되는 클라우드 리전은 us-east1, us-west1, europe-west1, asia-east1입니다. 리전을 지정하지 않으면 동영상 파일 위치를 기준으로 리전이 결정됩니다.

HTTP 메서드 및 URL:

POST https://automl.googleapis.com/v1beta1/projects/project-id/locations/location-id/operations/operation-id:cancel

요청을 보내려면 다음 옵션 중 하나를 펼칩니다.

성공 상태 코드(2xx)와 빈 응답을 받게 됩니다.

Java

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


import com.google.cloud.automl.v1beta1.AutoMlClient;
import io.grpc.StatusRuntimeException;
import java.io.IOException;

class CancelOperation {

  static void cancelOperation() throws IOException, InterruptedException, StatusRuntimeException {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "YOUR_PROJECT_ID";
    String location = "us-central1";
    String operationId = "YOUR_OPERATION_ID";
    String operationFullId =
        String.format("projects/%s/locations/%s/operations/%s", projectId, location, operationId);
    cancelOperation(operationFullId);
  }

  static void cancelOperation(String operationFullId)
      throws IOException, InterruptedException, StatusRuntimeException {
    // 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 (AutoMlClient client = AutoMlClient.create()) {
      client.getOperationsClient().cancelOperation(operationFullId);
      System.out.println("Operation cancelled");
    }
  }
}

모델 정보 가져오기

학습이 완료되면 새로 생성된 모델에 대한 정보를 얻을 수 있습니다.

이 섹션의 예시에서는 모델에 대한 기본 메타데이터를 반환합니다. 모델의 정확성 및 준비상태에 대한 자세한 내용은 모델 평가를 참조하세요.

웹 UI

  1. AutoML Video Object Tracking UI에서 모델 페이지로 이동합니다.

    하나의 모델이 표시된 모델 페이지
  2. 보려는 모델의 이름을 클릭합니다.

REST

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

  • model-id: 모델을 만들 때의 응답에서 나온 모델의 ID입니다. ID는 모델 이름의 마지막 요소입니다. 예시:
    • 모델 이름: projects/project-number/locations/location-id/models/model-id
    • 모델 ID: model-id
  • dataset-id: 데이터 세트의 데이터 세트 식별자(표시 이름이 아님)로 바꿉니다. 예를 들면 VOT3940649673949184000입니다.
  • project-number: 프로젝트 수입니다.

HTTP 메서드 및 URL:

GET https://automl.googleapis.com/v1beta1/projects/project-id/locations/location-id/models/model-id

JSON 요청 본문:

{
  "displayName": "display-name",
  "dataset_id": "dataset-id",
  "videoClassificationModelMetadata": {}
}

요청을 보내려면 다음 옵션 중 하나를 펼칩니다.

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

Java

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

import com.google.cloud.automl.v1beta1.AutoMlClient;
import com.google.cloud.automl.v1beta1.Model;
import com.google.cloud.automl.v1beta1.ModelName;
import io.grpc.StatusRuntimeException;
import java.io.IOException;

class GetModel {

  static void getModel() throws IOException, StatusRuntimeException {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "YOUR_PROJECT_ID";
    String modelId = "YOUR_MODEL_ID";
    getModel(projectId, modelId);
  }

  // Get a model
  static void getModel(String projectId, String modelId)
      throws IOException, StatusRuntimeException {
    // 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 (AutoMlClient client = AutoMlClient.create()) {
      // Get the full path of the model.
      ModelName modelFullId = ModelName.of(projectId, "us-central1", modelId);
      Model model = client.getModel(modelFullId);

      // Display the model information.
      System.out.format("Model name: %s%n", model.getName());
      // To get the model id, you have to parse it out of the `name` field. As models Ids are
      // required for other methods.
      // Name Format: `projects/{project_id}/locations/{location_id}/models/{model_id}`
      String[] names = model.getName().split("/");
      String retrievedModelId = names[names.length - 1];
      System.out.format("Model id: %s%n", retrievedModelId);
      System.out.format("Model display name: %s%n", model.getDisplayName());
      System.out.println("Model create time:");
      System.out.format("\tseconds: %s%n", model.getCreateTime().getSeconds());
      System.out.format("\tnanos: %s%n", model.getCreateTime().getNanos());
      System.out.format("Model deployment state: %s%n", model.getDeploymentState());
    }
  }
}

Node.js

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

/**
 * TODO(developer): Uncomment these variables before running the sample.
 */
// const projectId = 'YOUR_PROJECT_ID';
// const location = 'us-central1';
// const modelId = 'YOUR_MODEL_ID';

// Imports the Google Cloud AutoML library
const {AutoMlClient} = require('@google-cloud/automl').v1beta1;

// Instantiates a client
const client = new AutoMlClient();

async function getModel() {
  // Construct request
  const request = {
    name: client.modelPath(projectId, location, modelId),
  };

  const [response] = await client.getModel(request);

  console.log(`Model name: ${response.name}`);
  console.log(
    `Model id: ${
      response.name.split('/')[response.name.split('/').length - 1]
    }`
  );
  console.log(`Model display name: ${response.displayName}`);
  console.log('Model create time');
  console.log(`\tseconds ${response.createTime.seconds}`);
  console.log(`\tnanos ${response.createTime.nanos / 1e9}`);
  console.log(`Model deployment state: ${response.deploymentState}`);
}

getModel();

Python

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

from google.cloud import automl_v1beta1 as automl

# TODO(developer): Uncomment and set the following variables
# project_id = "YOUR_PROJECT_ID"
# model_id = "YOUR_MODEL_ID"

client = automl.AutoMlClient()
# Get the full path of the model.
model_full_id = client.model_path(project_id, "us-central1", model_id)
model = client.get_model(name=model_full_id)

# Retrieve deployment state.
if model.deployment_state == automl.Model.DeploymentState.DEPLOYED:
    deployment_state = "deployed"
else:
    deployment_state = "undeployed"

# Display the model information.
print(f"Model name: {model.name}")
print("Model id: {}".format(model.name.split("/")[-1]))
print(f"Model display name: {model.display_name}")
print(f"Model create time: {model.create_time}")
print(f"Model deployment state: {deployment_state}")

모델 나열

프로젝트는 수많은 모델을 포함할 수 있습니다. 이 섹션에서는 프로젝트에 사용할 수 있는 모델 목록을 검색하는 방법에 대해 설명합니다.

웹 UI

AutoML Video Object Tracking UI에서 모델 페이지로 이동합니다.

하나의 모델이 목록에 있는 모델 페이지

다른 프로젝트의 모델을 보려면 제목 표시줄 오른쪽 위에 있는 드롭다운 목록에서 프로젝트를 선택하세요.

REST

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

  • project-number: 프로젝트 수입니다.
  • location-id: 주석이 있어야 할 클라우드 리전입니다. 지원되는 클라우드 리전은 us-east1, us-west1, europe-west1, asia-east1입니다. 리전을 지정하지 않으면 동영상 파일 위치를 기준으로 리전이 결정됩니다.

HTTP 메서드 및 URL:

GET https://automl.googleapis.com/v1beta1/projects/project-number/locations/location-id/models

요청을 보내려면 다음 옵션 중 하나를 펼칩니다.

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

Java

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

import com.google.cloud.automl.v1beta1.AutoMlClient;
import com.google.cloud.automl.v1beta1.ListModelsRequest;
import com.google.cloud.automl.v1beta1.LocationName;
import com.google.cloud.automl.v1beta1.Model;
import java.io.IOException;

class ListModels {

  static void listModels() throws IOException {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "YOUR_PROJECT_ID";
    listModels(projectId);
  }

  // List the models available in the specified location
  static void listModels(String projectId) throws IOException {
    // 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 (AutoMlClient client = AutoMlClient.create()) {
      // A resource that represents Google Cloud Platform location.
      LocationName projectLocation = LocationName.of(projectId, "us-central1");

      // Create list models request.
      ListModelsRequest listModelsRequest =
          ListModelsRequest.newBuilder()
              .setParent(projectLocation.toString())
              .setFilter("")
              .build();

      // List all the models available in the region by applying filter.
      System.out.println("List of models:");
      for (Model model : client.listModels(listModelsRequest).iterateAll()) {
        // Display the model information.
        System.out.format("Model name: %s%n", model.getName());
        // To get the model id, you have to parse it out of the `name` field. As models Ids are
        // required for other methods.
        // Name Format: `projects/{project_id}/locations/{location_id}/models/{model_id}`
        String[] names = model.getName().split("/");
        String retrievedModelId = names[names.length - 1];
        System.out.format("Model id: %s%n", retrievedModelId);
        System.out.format("Model display name: %s%n", model.getDisplayName());
        System.out.println("Model create time:");
        System.out.format("\tseconds: %s%n", model.getCreateTime().getSeconds());
        System.out.format("\tnanos: %s%n", model.getCreateTime().getNanos());
        System.out.format("Model deployment state: %s%n", model.getDeploymentState());
      }
    }
  }
}

Node.js

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

/**
 * TODO(developer): Uncomment these variables before running the sample.
 */
// const projectId = 'YOUR_PROJECT_ID';
// const location = 'us-central1';

// Imports the Google Cloud AutoML library
const {AutoMlClient} = require('@google-cloud/automl').v1beta1;

// Instantiates a client
const client = new AutoMlClient();

async function listModels() {
  // Construct request
  const request = {
    parent: client.locationPath(projectId, location),
    filter: 'translation_model_metadata:*',
  };

  const [response] = await client.listModels(request);

  console.log('List of models:');
  for (const model of response) {
    console.log(`Model name: ${model.name}`);
    console.log(`
      Model id: ${model.name.split('/')[model.name.split('/').length - 1]}`);
    console.log(`Model display name: ${model.displayName}`);
    console.log('Model create time');
    console.log(`\tseconds ${model.createTime.seconds}`);
    console.log(`\tnanos ${model.createTime.nanos / 1e9}`);
    console.log(`Model deployment state: ${model.deploymentState}`);
  }
}

listModels();

Python

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

from google.cloud import automl_v1beta1 as automl

# TODO(developer): Uncomment and set the following variables
# project_id = "YOUR_PROJECT_ID"

client = automl.AutoMlClient()
# A resource that represents Google Cloud Platform location.
project_location = f"projects/{project_id}/locations/us-central1"
request = automl.ListModelsRequest(parent=project_location, filter="")
response = client.list_models(request=request)

print("List of models:")
for model in response:
    # Display the model information.
    if model.deployment_state == automl.Model.DeploymentState.DEPLOYED:
        deployment_state = "deployed"
    else:
        deployment_state = "undeployed"

    print(f"Model name: {model.name}")
    print("Model id: {}".format(model.name.split("/")[-1]))
    print(f"Model display name: {model.display_name}")
    print(f"Model create time: {model.create_time}")
    print(f"Model deployment state: {deployment_state}")

모델 삭제

다음 예시에서는 모델을 삭제합니다.

웹 UI

  1. AutoML Video Object Tracking UI에서 모델 페이지로 이동합니다.

    하나의 모델이 표시된 모델 페이지
  2. 삭제하려는 행 맨 오른쪽에 있는 점 3개로 된 메뉴를 클릭하고 삭제를 클릭합니다.
  3. 확인 대화상자에서 확인을 클릭합니다.

REST

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

  • project-number: 프로젝트 수입니다.
  • location-id: 주석이 있어야 할 클라우드 리전입니다. 지원되는 클라우드 리전은 us-east1, us-west1, europe-west1, asia-east1입니다. 리전을 지정하지 않으면 동영상 파일 위치를 기준으로 리전이 결정됩니다.
  • model-id: 모델의 식별자로 바꿉니다.

HTTP 메서드 및 URL:

DELETE https://automl.googleapis.com/v1beta1/projects/project-number/locations/location-id/models/model-id

요청을 보내려면 다음 옵션 중 하나를 펼칩니다.

성공 상태 코드(2xx)와 빈 응답을 받게 됩니다.

Java

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

import com.google.cloud.automl.v1beta1.AutoMlClient;
import com.google.cloud.automl.v1beta1.ModelName;
import com.google.protobuf.Empty;
import java.io.IOException;
import java.util.concurrent.ExecutionException;

class DeleteModel {

  public static void main(String[] args)
      throws IOException, ExecutionException, InterruptedException {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "YOUR_PROJECT_ID";
    String modelId = "YOUR_MODEL_ID";
    deleteModel(projectId, modelId);
  }

  // Delete a model
  static void deleteModel(String projectId, String modelId)
      throws IOException, ExecutionException, InterruptedException {
    // 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 (AutoMlClient client = AutoMlClient.create()) {
      // Get the full path of the model.
      ModelName modelFullId = ModelName.of(projectId, "us-central1", modelId);

      // Delete a model.
      Empty response = client.deleteModelAsync(modelFullId).get();

      System.out.println("Model deletion started...");
      System.out.println(String.format("Model deleted. %s", response));
    }
  }
}

Node.js

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

/**
 * TODO(developer): Uncomment these variables before running the sample.
 */
// const projectId = 'YOUR_PROJECT_ID';
// const location = 'us-central1';
// const modelId = 'YOUR_MODEL_ID';

// Imports the Google Cloud AutoML library
const {AutoMlClient} = require('@google-cloud/automl').v1beta1;

// Instantiates a client
const client = new AutoMlClient();

async function deleteModel() {
  // Construct request
  const request = {
    name: client.modelPath(projectId, location, modelId),
  };

  const [response] = await client.deleteModel(request);
  console.log(`Model deleted: ${response}`);
}

deleteModel();

Python

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

from google.cloud import automl_v1beta1 as automl

# TODO(developer): Uncomment and set the following variables
# project_id = "YOUR_PROJECT_ID"
# model_id = "YOUR_MODEL_ID"

client = automl.AutoMlClient()
# Get the full path of the model.
model_full_id = client.model_path(project_id, "us-central1", model_id)
response = client.delete_model(name=model_full_id)

print(f"Model deleted. {response.result()}")