데이터 세트 관리

데이터 세트에는 라벨을 지정할 콘텐츠 유형의 대표 샘플과 모델에서 사용할 경계 상자 라벨이 들어 있습니다. 데이터세트는 모델 학습을 위한 입력으로 사용됩니다.

데이터 세트 빌드의 주요 단계는 다음과 같습니다.

  1. 데이터 세트 생성 및 각 항목에 여러 개의 라벨을 적용할지 여부를 지정
  2. 데이터 세트로 데이터 항목 가져오기

학습 전에 모델을 학습하기 전에 데이터를 준비했는지 확인하세요.

프로젝트에는 여러 개의 데이터 세트를 적용할 수 있으며 각 데이터 세트는 별도의 모델 학습에 사용됩니다. 사용 가능한 데이터 세트 목록을 가져오거나 필요 없는 데이터 세트를 삭제할 수 있습니다.

데이터세트 만들기

모델을 생성하는 첫 단계는 모델 학습용 데이터를 저장할 비어 있는 데이터 세트를 만드는 것입니다.

웹 UI

AutoML Video Object Tracking UI를 사용하면 새 데이터 세트를 만들고 같은 페이지에서 항목을 해당 데이터 세트에 가져올 수 있습니다.

  1. AutoML Video Object Tracking UI를 엽니다. 데이터 세트 페이지에는 현재 프로젝트를 위해 이전에 작성한 데이터 세트의 상태가 표시됩니다. Google Cloud Console의 프로젝트 데이터 세트 목록 다른 프로젝트를 위한 데이터 세트를 추가하려면 제목 표시줄의 오른쪽 위에 있는 드롭다운 목록에서 프로젝트를 선택하세요.
  2. 데이터 세트 페이지에서 데이터 세트 만들기를 클릭합니다.
  3. 데이터 세트 만들기 대화상자에서 다음을 수행합니다.
    • 데이터 세트의 이름을 지정합니다.
    • 동영상 객체 추적을 선택합니다.
    • 데이터 세트 만들기를 클릭합니다.
  4. 데이터 세트 페이지에서 학습 데이터의 URI가 포함된 CSV 파일의 Cloud Storage URI를 지정합니다(시작 부분에 gs:// 프리픽스 사용 안 함).
  5. 또한 데이터 세트 페이지에서 계속을 클릭하여 가져오기를 시작합니다. 제목이 'my_dataset'인 데이터 세트 페이지

REST

다음 예시에서는 객체 추적 사용 사례를 지원하는 my_dataset01라는 데이터 세트를 만듭니다. 새로 생성된 데이터 세트에는 항목을 가져올 때까지는 어떤 데이터도 포함되지 않습니다.

데이터 세트로 항목 가져오기나 모델 학습과 같은 다른 작업에 사용할 수 있도록 (응답에서) 새 데이터 세트의 "name"을 저장합니다.

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

  • dataset-name: 대상 데이터 세트의 이름입니다.
    예를 들면 my_dataset_01입니다.
  • 참고:
    • 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/datasets

JSON 요청 본문:

{
    "displayName": "dataset-name",
    "videoObjectTrackingDatasetMetadata": { }
}

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

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/datasets"

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/datasets" | Select-Object -Expand Content
응답이 성공하면 AutoML Video Intelligence 객체 추적 API가 작업의 이름을 반환합니다. 다음은 이러한 응답의 예시입니다. project-number는 프로젝트 수이며 operation-id는 요청에 대해 생성된 장기 실행 작업의 ID입니다. 예를 들면 다음과 같습니다. VOT12345....

Java

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

import com.google.cloud.automl.v1beta1.AutoMlClient;
import com.google.cloud.automl.v1beta1.Dataset;
import com.google.cloud.automl.v1beta1.LocationName;
import com.google.cloud.automl.v1beta1.VideoObjectTrackingDatasetMetadata;
import java.io.IOException;

class VideoObjectTrackingCreateDataset {

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

  // Create a dataset
  static void createDataset(String projectId, String displayName) 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");
      VideoObjectTrackingDatasetMetadata metadata =
          VideoObjectTrackingDatasetMetadata.newBuilder().build();
      Dataset dataset =
          Dataset.newBuilder()
              .setDisplayName(displayName)
              .setVideoObjectTrackingDatasetMetadata(metadata)
              .build();

      Dataset createdDataset = client.createDataset(projectLocation, dataset);

      // Display the dataset information.
      System.out.format("Dataset name: %s%n", createdDataset.getName());
      // To get the dataset id, you have to parse it out of the `name` field. As dataset Ids are
      // required for other methods.
      // Name Form: `projects/{project_id}/locations/{location_id}/datasets/{dataset_id}`
      String[] names = createdDataset.getName().split("/");
      String datasetId = names[names.length - 1];
      System.out.format("Dataset id: %s%n", datasetId);
    }
  }
}

Node.js

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

/**
 * TODO(developer): Uncomment these variables before running the sample.
 */
// const projectId = 'YOUR_PROJECT_ID';
// const location = 'us-central1';
// 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 createDataset() {
  // Construct request
  const request = {
    parent: client.locationPath(projectId, location),
    dataset: {
      displayName: displayName,
      videoObjectTrackingDatasetMetadata: {},
    },
  };

  // Create dataset
  const [response] = await client.createDataset(request);

  console.log(`Dataset name: ${response.name}`);
  console.log(`
    Dataset id: ${
      response.name
        .split('/')
        [response.name.split('/').length - 1].split('\n')[0]
    }`);
}

createDataset();

Python

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

from google.cloud import automl_v1beta1 as automl


def create_dataset(
    project_id="YOUR_PROJECT_ID", display_name="your_datasets_display_name"
):
    """Create a automl video object tracking dataset."""
    client = automl.AutoMlClient()

    # A resource that represents Google Cloud Platform location.
    project_location = f"projects/{project_id}/locations/us-central1"
    metadata = automl.VideoObjectTrackingDatasetMetadata()
    dataset = automl.Dataset(
        display_name=display_name,
        video_object_tracking_dataset_metadata=metadata,
    )

    # Create a dataset with the dataset metadata in the region.
    created_dataset = client.create_dataset(parent=project_location, dataset=dataset)
    # Display the dataset information
    print(f"Dataset name: {created_dataset.name}")
    print("Dataset id: {}".format(created_dataset.name.split("/")[-1]))

데이터 세트로 항목 가져오기

데이터 세트를 만든 후에는 Cloud Storage 버킷에 저장된 CSV 파일에서 라벨이 지정된 데이터를 가져올 수 있습니다. 데이터 준비 및 가져올 CSV 파일 만들기에 대한 자세한 내용은 학습 데이터 준비를 참조하세요.

항목을 비어 있는 데이터세트로 가져오거나 추가 항목을 기존 데이터세트로 가져올 수 있습니다.

웹 UI

일반적으로 데이터 세트를 만들 때 데이터를 가져옵니다.

그러나 데이터 세트를 만든 후에 데이터를 가져와야 하는 경우 다음을 수행하세요.

  1. AutoML Video Object Tracking UI를 엽니다. 데이터 세트 페이지에는 현재 프로젝트를 위해 이전에 작성한 데이터 세트의 상태가 표시됩니다. Google Cloud Console의 프로젝트 데이터 세트 목록
  2. 목록에서 데이터를 가져올 데이터 세트를 클릭합니다.
  3. 가져오기 탭에서 시작 부분에 gs:// 프리픽스가 없는 학습 데이터의 URI가 포함된 CSV 파일의 Cloud Storage URI를 제공합니다.
  4. 또한 데이터 세트의 가져오기 탭에서 계속을 클릭하여 가져오기를 시작합니다. 제목이 'my_dataset'인 데이터 세트 페이지

REST

학습 데이터를 가져오려면 importData 메서드를 사용합니다. 이 메서드를 사용하려면 다음 두 매개변수를 제공해야 합니다.

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

  • dataset-id: 데이터 세트의 ID입니다. ID는 데이터 세트 이름의 마지막 요소입니다. 예를 들면 다음과 같습니다.
    • 데이터 세트 이름: projects/project-number/locations/location-id/datasets/3104518874390609379
    • 데이터 세트 ID: 3104518874390609379
  • bucket-name: 모델 학습 파일 목록 CSV 파일을 저장한 Cloud Storage 버킷의 이름으로 바꿉니다.
  • csv-file-name: 모델 학습 파일 목록 CSV 파일의 이름으로 바꿉니다.
  • 참고:
    • 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/datasets/dataset-id:importData

JSON 요청 본문:

{
  "inputConfig": {
    "gcsSource": {
      "inputUris": ["gs://bucket-name/csv-file-name.csv"]
    }
  }
}

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

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/datasets/dataset-id:importData"

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/datasets/dataset-id:importData" | Select-Object -Expand Content
데이터 가져오기 작업의 작업 ID를 받아야 합니다. 이 예시는 가져오기 작업 ID VOT7506374678919774208가 포함 된 응답을 보여줍니다.

Java

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

import com.google.api.gax.longrunning.OperationFuture;
import com.google.api.gax.retrying.RetrySettings;
import com.google.cloud.automl.v1beta1.AutoMlClient;
import com.google.cloud.automl.v1beta1.AutoMlSettings;
import com.google.cloud.automl.v1beta1.DatasetName;
import com.google.cloud.automl.v1beta1.GcsSource;
import com.google.cloud.automl.v1beta1.InputConfig;
import com.google.cloud.automl.v1beta1.OperationMetadata;
import com.google.protobuf.Empty;
import java.io.IOException;
import java.util.Arrays;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.threeten.bp.Duration;

class ImportDataset {

  public static void main(String[] args)
      throws IOException, ExecutionException, InterruptedException, TimeoutException {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "YOUR_PROJECT_ID";
    String datasetId = "YOUR_DATASET_ID";
    String path = "gs://BUCKET_ID/path_to_training_data.csv";
    importDataset(projectId, datasetId, path);
  }

  // Import a dataset
  static void importDataset(String projectId, String datasetId, String path)
      throws IOException, ExecutionException, InterruptedException, TimeoutException {
    Duration totalTimeout = Duration.ofMinutes(45);
    RetrySettings retrySettings = RetrySettings.newBuilder().setTotalTimeout(totalTimeout).build();
    AutoMlSettings.Builder builder = AutoMlSettings.newBuilder();
    builder.importDataSettings().setRetrySettings(retrySettings).build();
    AutoMlSettings settings = builder.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 (AutoMlClient client = AutoMlClient.create(settings)) {
      // Get the complete path of the dataset.
      DatasetName datasetFullId = DatasetName.of(projectId, "us-central1", datasetId);

      // Get multiple Google Cloud Storage URIs to import data from
      GcsSource gcsSource =
          GcsSource.newBuilder().addAllInputUris(Arrays.asList(path.split(","))).build();

      // Import data from the input URI
      InputConfig inputConfig = InputConfig.newBuilder().setGcsSource(gcsSource).build();
      System.out.println("Processing import...");

      // Start the import job
      OperationFuture<Empty, OperationMetadata> operation =
          client.importDataAsync(datasetFullId, inputConfig);

      System.out.format("Operation name: %s%n", operation.getName());

      // If you want to wait for the operation to finish, adjust the timeout appropriately. The
      // operation will still run if you choose not to wait for it to complete. You can check the
      // status of your operation using the operation's name.
      Empty response = operation.get(45, TimeUnit.MINUTES);
      System.out.format("Dataset imported. %s%n", response);
    } catch (TimeoutException e) {
      System.out.println("The operation's polling period was not long enough.");
      System.out.println("You can use the Operation's name to get the current status.");
      System.out.println("The import job is still running and will complete as expected.");
      throw e;
    }
  }
}

Node.js

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

/**
 * TODO(developer): Uncomment these variables before running the sample.
 */
// const projectId = 'YOUR_PROJECT_ID';
// const location = 'us-central1';
// const datasetId = 'YOUR_DISPLAY_ID';
// const path = 'gs://BUCKET_ID/path_to_training_data.csv';

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

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

async function importDataset() {
  // Construct request
  const request = {
    name: client.datasetPath(projectId, location, datasetId),
    inputConfig: {
      gcsSource: {
        inputUris: path.split(','),
      },
    },
  };

  // Import dataset
  console.log('Proccessing import');
  const [operation] = await client.importData(request);

  // Wait for operation to complete.
  const [response] = await operation.promise();
  console.log(`Dataset imported: ${response}`);
}

importDataset();

Python

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

from google.cloud import automl_v1beta1 as automl


def import_dataset(
    project_id="YOUR_PROJECT_ID",
    dataset_id="YOUR_DATASET_ID",
    path="gs://YOUR_BUCKET_ID/path/to/data.csv",
):
    """Import a dataset."""
    client = automl.AutoMlClient()
    # Get the full path of the dataset.
    dataset_full_id = client.dataset_path(project_id, "us-central1", dataset_id)
    # Get the multiple Google Cloud Storage URIs
    input_uris = path.split(",")
    gcs_source = automl.GcsSource(input_uris=input_uris)
    input_config = automl.InputConfig(gcs_source=gcs_source)
    # Import data from the input URI
    response = client.import_data(name=dataset_full_id, input_config=input_config)

    print("Processing import...")
    print(f"Data imported. {response.result()}")

학습 항목 라벨 지정하기

모델 학습에 유용하려면 데이터 세트에 있는 각 항목은 경계 상자와 카테고리 라벨이 각각 하나 이상 지정되어야 합니다. 다음 두 가지 방법으로 학습 항목의 라벨과 경계 상자를 제공할 수 있습니다.

  • CSV 파일에 라벨 및 경계 상자 포함
  • AutoML Video Object Tracking UI에서 라벨 및 경계 상자 적용

CSV 파일에서 항목 라벨을 지정하는 방법에 대한 자세한 내용은 학습 데이터 준비를 참조하세요.

AutoML Video Object Tracking UI에서 항목에 라벨을 지정하려면 데이터 세트 목록 페이지에서 데이터 세트를 선택하여 세부정보를 확인합니다. 선택한 데이터 세트의 이름이 제목 표시줄에 나타나고 페이지에는 데이터 세트에 있는 개별 항목이 라벨과 함께 나열됩니다. 왼쪽의 탐색 메뉴에 라벨이 지정된 항목과 라벨이 지정되지 않은 항목 수에 대한 요약 정보가 표시됩니다. 또한 라벨별로 항목 목록을 필터링할 수 있습니다.

데이터 세트의 동영상

라벨이 지정되지 않은 동영상에 라벨 및 경계 상자를 할당하거나 동영상 라벨 및 경계 상자를 변경하려면 다음을 수행하세요.

  1. 데이터 세트 페이지에서 라벨을 추가할 동영상을 클릭합니다.
  2. 동영상 페이지에서 다음을 수행합니다.

    1. 라벨을 지정할 항목이 표시될 때까지 동영상을 실행합니다.
    2. 커서를 드래그하여 항목 주위에 경계 상자를 그립니다.
    3. 경계 상자를 그린 후 사용하려는 라벨을 선택합니다.
    4. 저장을 클릭합니다.

동영상에서 소 주변에 경계 상자 그리기

데이터 세트의 새 라벨을 추가해야 할 경우 데이터 세트 페이지의 기존 라벨 목록 위에서 라벨 필터링 옆에 있는 세 개의 점을 클릭한 후 새 라벨 추가를 클릭합니다.

데이터 라벨 변경

데이터 세트의 동영상에 적용된 라벨을 변경할 수도 있습니다. AutoML Video Object Tracking UI에서 다음을 수행합니다.

  1. 데이터 세트 페이지에서 라벨을 변경할 동영상을 클릭합니다.
  2. 동영상 페이지에서 다음을 수행합니다.

    1. 왼쪽 라벨 목록에서 변경하려는 라벨을 선택합니다.
    2. 동영상 미리보기에서 동영상의 경계 상자를 마우스 오른쪽 버튼으로 클릭하고 원하는 라벨을 선택합니다.
    3. 저장을 클릭합니다.

동영상의 세단에 적용된 라벨 변경하기

데이터 세트 나열

프로젝트에는 수많은 데이터 세트가 포함될 수 있습니다. 이 섹션에서는 프로젝트에 사용할 수 있는 데이터 세트의 목록을 검색하는 방법을 설명합니다.

웹 UI

AutoML Video Object Tracking UI를 사용하여 사용 가능한 데이터 세트 목록을 보려면 데이터 세트 페이지로 이동하세요.

프로젝트의 데이터 세트 목록

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

REST

다음 curl 또는 PowerShell 명령어를 사용하여 데이터 세트 목록과 데이터 세트로 가져온 샘플 동영상 수를 가져옵니다.

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

  • 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/datasets

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

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/datasets "

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/datasets " | Select-Object -Expand Content
아래 응답에서 VOT3940649673949184000는 작업을 시작할 때 요청으로 생성되고 응답에서 제공되는 장기 실행 작업의 작업 ID입니다.

Java

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

import com.google.cloud.automl.v1beta1.AutoMlClient;
import com.google.cloud.automl.v1beta1.Dataset;
import com.google.cloud.automl.v1beta1.ListDatasetsRequest;
import com.google.cloud.automl.v1beta1.LocationName;
import java.io.IOException;

class ListDatasets {

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

  // List the datasets
  static void listDatasets(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");
      ListDatasetsRequest request =
          ListDatasetsRequest.newBuilder().setParent(projectLocation.toString()).build();

      // List all the datasets available in the region by applying filter.
      System.out.println("List of datasets:");
      for (Dataset dataset : client.listDatasets(request).iterateAll()) {
        // Display the dataset information
        System.out.format("%nDataset name: %s%n", dataset.getName());
        // To get the dataset id, you have to parse it out of the `name` field. As dataset Ids are
        // required for other methods.
        // Name Form: `projects/{project_id}/locations/{location_id}/datasets/{dataset_id}`
        String[] names = dataset.getName().split("/");
        String retrievedDatasetId = names[names.length - 1];
        System.out.format("Dataset id: %s%n", retrievedDatasetId);
        System.out.format("Dataset display name: %s%n", dataset.getDisplayName());
        System.out.println("Dataset create time:");
        System.out.format("\tseconds: %s%n", dataset.getCreateTime().getSeconds());
        System.out.format("\tnanos: %s%n", dataset.getCreateTime().getNanos());

        System.out.format(
            "Video object tracking dataset metadata: %s%n",
            dataset.getVideoObjectTrackingDatasetMetadata());
      }
    }
  }
}

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 listDatasets() {
  // Construct request
  const request = {
    parent: client.locationPath(projectId, location),
    filter: 'translation_dataset_metadata:*',
  };

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

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

    console.log(
      `Video object tracking dataset metadata: ${dataset.videoObjectTrackingDatasetMetadata}`
    );
  }
}

listDatasets();

Python

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

from google.cloud import automl_v1beta1 as automl


def list_datasets(project_id="YOUR_PROJECT_ID"):
    """List datasets."""
    client = automl.AutoMlClient()
    # A resource that represents Google Cloud Platform location.
    project_location = f"projects/{project_id}/locations/us-central1"

    # List all the datasets available in the region.
    request = automl.ListDatasetsRequest(parent=project_location, filter="")
    response = client.list_datasets(request=request)

    print("List of datasets:")
    for dataset in response:
        print(f"Dataset name: {dataset.name}")
        print("Dataset id: {}".format(dataset.name.split("/")[-1]))
        print(f"Dataset display name: {dataset.display_name}")
        print(f"Dataset create time: {dataset.create_time}")
        print(
            "Video object tracking dataset metadata: {}".format(
                dataset.video_object_tracking_dataset_metadata
            )
        )

데이터 세트 삭제

다음 코드는 데이터 세트를 삭제하는 방법을 보여줍니다.

웹 UI

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

    데이터 세트 탭
  2. 삭제하려는 행 맨 오른쪽에 있는 점 3개로 된 메뉴를 클릭하고 데이터 세트 삭제를 클릭합니다.
  3. 확인 대화상자에서 확인을 클릭합니다.

REST

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

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

HTTP 메서드 및 URL:

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

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

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

Java

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

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

class DeleteDataset {

  static void deleteDataset() throws IOException, ExecutionException, InterruptedException {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "YOUR_PROJECT_ID";
    String datasetId = "YOUR_DATASET_ID";
    deleteDataset(projectId, datasetId);
  }

  // Delete a dataset
  static void deleteDataset(String projectId, String datasetId)
      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 dataset.
      DatasetName datasetFullId = DatasetName.of(projectId, "us-central1", datasetId);
      Empty response = client.deleteDatasetAsync(datasetFullId).get();
      System.out.format("Dataset deleted. %s%n", response);
    }
  }
}

Node.js

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

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

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

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

async function deleteDataset() {
  // Construct request
  const request = {
    name: client.datasetPath(projectId, location, datasetId),
  };

  const [operation] = await client.deleteDataset(request);

  // Wait for operation to complete.
  const [response] = await operation.promise();
  console.log(`Dataset deleted: ${response}`);
}

deleteDataset();

Python

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

from google.cloud import automl_v1beta1 as automl


def delete_dataset(project_id="YOUR_PROJECT_ID", dataset_id="YOUR_DATASET_ID"):
    """Delete a dataset."""
    client = automl.AutoMlClient()
    # Get the full path of the dataset
    dataset_full_id = client.dataset_path(project_id, "us-central1", dataset_id)
    response = client.delete_dataset(name=dataset_full_id)

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