데이터세트 관리

데이터세트에는 커스텀 모델이 사용할 카테고리 라벨로 지정해 분류하려는 콘텐츠 유형의 대표 샘플이 있습니다. 데이터 세트는 모델 학습을 위한 입력으로 사용됩니다.

데이터 세트 구축을 위한 주요 단계는 다음과 같습니다.

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

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

데이터 세트 만들기

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

웹 UI

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

  1. AutoML Video UI를 엽니다. 데이터 세트 페이지에는 현재 프로젝트를 위해 이전에 작성한 데이터 세트의 상태가 표시됩니다. 다른 프로젝트를 위한 데이터 세트를 추가하려면 제목 표시줄의 오른쪽 위에 있는 드롭다운 목록에서 프로젝트를 선택하세요.
  2. 데이터 세트 페이지에서 데이터 세트 만들기를 클릭합니다.
    데이터 세트 만들기 아이콘

    다음 화면이 표시됩니다. Click_new_dataset
  3. 데이터 세트에 대한 정보를 입력합니다.
    1. 데이터 세트의 이름을 지정합니다.
    2. 동영상 분류를 선택합니다.
    3. 데이터 세트 만들기를 클릭합니다.

      다음 화면이 표시됩니다. 'my_dataset'라는 데이터 세트 페이지
  4. 다음 정보를 입력합니다.
    1. 학습 데이터의 URI가 포함된 CSV 파일의 Cloud Storage URI를 제공합니다(데이터 준비 참조).
      이 빠른 시작에서는 다음을 사용합니다.
      automl-video-demo-data/hmdb_split1.csv

    2. 계속을 클릭하여 데이터 가져오기를 시작합니다.
      다음 화면이 표시됩니다.
      데이터 가져오기

제공한 동영상의 수와 길이에 따라 가져오기 과정을 완료하는 데 다소 시간이 걸릴 수 있습니다.

REST

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

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

JSON 요청 본문:

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

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

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 Classification API가 작업의 name을 반환합니다. 다음은 이러한 응답의 예시를 보여줍니다. 여기서 project-number는 프로젝트 수이고, operation-id는 요청에 대해 생성된 장기 실행 작업의 ID입니다.

Java

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

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.VideoClassificationDatasetMetadata;
import java.io.IOException;

class VideoClassificationCreateDataset {

  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");
      VideoClassificationDatasetMetadata metadata =
          VideoClassificationDatasetMetadata.newBuilder().build();
      Dataset dataset =
          Dataset.newBuilder()
              .setDisplayName(displayName)
              .setVideoClassificationDatasetMetadata(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 Video에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

/**
 * 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,
      videoClassificationDatasetMetadata: {},
    },
  };

  // 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 Video에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

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 classification dataset."""

    client = automl.AutoMlClient()

    # A resource that represents Google Cloud Platform location.
    project_location = f"projects/{project_id}/locations/us-central1"
    metadata = automl.VideoClassificationDatasetMetadata()
    dataset = automl.Dataset(
        display_name=display_name,
        video_classification_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}")

    # 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}`
    print("Dataset id: {}".format(created_dataset.name.split("/")[-1]))

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

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

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

웹 UI

데이터세트를 만들 때 데이터를 가져옵니다.

REST

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

  • input-uri: 파일 이름을 포함하여 주석을 추가하고자 하는 파일을 포함한 Cloud Storage 버킷입니다. gs://로 시작해야 합니다. 예시:
    "inputUris": ["gs://automl-video-demo-data/hmdb_split1.csv"]
  • dataset-id: 데이터 세트의 데이터 세트 식별자 (표시 이름이 아님)로 바꾸세요. 예를 들면 VCN4798585402963263488입니다.
  • 참고:
    • 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": input-uri
      }
   }
}

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

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 VCN7506374678919774208가 포함 된 응답을 보여줍니다.

작업 ID를 사용하여 작업 상태를 가져올 수 있습니다. 예시를 보려면 작업 상태 가져오기를 참조하세요.

Java

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

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 Video에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

/**
 * 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 Video에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

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()}")

학습 항목 라벨 지정하기

데이터 세트에 있는 각 항목에 카테고리 라벨이 하나 이상 지정되어야 모델 학습에 유용합니다. AutoML Video는 카테고리 라벨이 없는 항목을 무시합니다. 다음 두 가지 방법으로 학습 항목에 라벨을 제공할 수 있습니다.

  • CSV 파일에 라벨 포함
  • AutoML Video UI의 항목에 라벨 지정

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

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

데이터 세트의 동영상

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

  1. 데이터세트 페이지에서 라벨을 추가하거나 변경하려는 동영상을 클릭합니다.
  2. 동영상 페이지에서 다음을 수행합니다.

    1. 세그먼트 추가를 클릭합니다.
    2. 동영상 타임라인의 양쪽에 있는 화살표를 드래그하여 라벨을 지정할 리전을 정의합니다. 기본적으로 동영상의 전체 재생 시간이 선택됩니다.
    3. 라벨 목록에서 동영상에 적용할 라벨을 클릭합니다. 라벨을 선택하면 해당 라벨의 색상 막대가 단색으로 바뀝니다.
    4. 저장을 클릭합니다.

계단을 올라가는 사람의 동영상에 라벨 적용하기

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

데이터세트 나열

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

웹 UI

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

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

REST

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

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

HTTP 메서드 및 URL:

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

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

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

Java

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

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 classification dataset metadata: %s%n",
            dataset.getVideoClassificationDatasetMetadata());
      }
    }
  }
}

Node.js

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

/**
 * 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 classification dataset metadata: ${dataset.videoClassificationDatasetMetadata}`
    );
  }
}

listDatasets();

Python

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

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 classification dataset metadata: {}".format(
                dataset.video_classification_dataset_metadata
            )
        )

데이터 세트 삭제

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

웹 UI

  1. AutoML Video UI에서 데이터 세트 페이지로 이동합니다.

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

REST

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

  • dataset-name: 데이터 세트를 만들 때 응답의 데이터 세트 전체 이름입니다. 전체 이름 형식은 다음과 같습니다.
    projects/project-number/locations/location-id/datasets/dataset-id
    • project-number: 프로젝트 수입니다.
    • location-id: 주석이 있어야 할 Cloud 리전입니다. 지원되는 클라우드 리전은 us-east1, us-west1, europe-west1, asia-east1입니다. 리전을 지정하지 않으면 동영상 파일 위치를 기준으로 리전이 결정됩니다.
    • dataset-id: 데이터 세트를 만들 때 제공한 ID

HTTP 메서드 및 URL:

DELETE  https://automl.googleapis.com/v1beta1/dataset-name

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

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

Java

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

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 Video에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

/**
 * 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 Video에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

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()}")