准备工作

您必须先为您的项目启用 AI Platform 数据标签服务,然后才能使用该服务。

  1. Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  3. Make sure that billing is enabled for your Google Cloud project.

  4. Enable the Data Labeling API.

    Enable the API

  5. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  6. Make sure that billing is enabled for your Google Cloud project.

  7. Enable the Data Labeling API.

    Enable the API

  8. 安装 Google Cloud CLIGoogle Cloud CLI
  9. 按照说明创建服务账号并为该账号下载密钥文件
  10. GOOGLE_APPLICATION_CREDENTIALS 环境变量设置为您在创建服务账号时所下载的服务账号密钥文件的路径。
    export GOOGLE_APPLICATION_CREDENTIALS=KEY_FILE
  11. PROJECT_ID 环境变量设置为项目 ID
    export PROJECT_ID=YOUR_PROJECT_ID
    Data Labeling API 调用和资源名称中包含您的项目 ID。PROJECT_ID 环境变量提供了一种指定此 ID 的便捷方式。
  12. 将您的用户账号和服务账号添加到 Data Labeling Editor IAM 角色中。
    1. YOUR_USERID@YOUR_DOMAIN 替换为您的用户账号。
    2. SERVICE_ACCOUNT_NAME 替换为新服务账号的名称,例如 service-account1@myproject.iam.gserviceaccount.com
    gcloud auth login
    gcloud projects add-iam-policy-binding $PROJECT_ID 
    --member="user:YOUR_USERID@YOUR_DOMAIN"
    --role="roles/datalabeling.editor" gcloud projects add-iam-policy-binding $PROJECT_ID
    --member="serviceAccount:SERVICE_ACCOUNT_EMAIL"
    --role="roles/datalabeling.editor"
  13. 创建一个 Google Cloud Storage 存储分区,以存储您想要添加标签的数据和提供给标签添加者的说明。