【问题标题】:Google Cloud-Vision API Sample Code returns Resource exhausted errorGoogle Cloud-Vision API 示例代码返回资源耗尽错误
【发布时间】:2020-04-07 17:41:27
【问题描述】:

我正在运行来自 cloud-vision API 示例存储库的以下代码。我已按照此处的说明进行操作:https://cloud.google.com/vision/docs/quickstart-client-libraries?refresh=1 设置服务帐户和身份验证,但我仍然无法成功执行此功能。

async function detectLabels() {
  // [START vision_label_detection]
  // Imports the Google Cloud client library
  const vision = require('@google-cloud/vision');

  // Creates a client
  const client = new vision.ImageAnnotatorClient();

  const fileName = './src/img/wakeupcat.jpg';

  // Performs label detection on the local file
  const [result] = await client.labelDetection(fileName);
  const labels = result.labelAnnotations;
  console.log('Labels:');
  labels.forEach(label => console.log(label.description));
  // [END vision_label_detection]
}

detectLabels();

这会产生以下错误:

错误:8 RESOURCE_EXHAUSTED:配额指标“请求”超出配额,并限制消费者“project_number:6579173653”的服务“vision.googleapis.com”的“每分钟请求数”。

我使用的 wakupcat.jpg 图像为 14kb,所以不是大小问题。

【问题讨论】:

    标签: google-cloud-platform google-api google-cloud-vision google-cloud-sdk


    【解决方案1】:

    您收到的错误是您发出的请求数量(我认为不是文件大小)。

    您可以使用以下 URL 查看特定项目和 API 的当前报价使用情况:

    https://console.cloud.google.com/apis/api/vision-json.googleapis.com/quotas?folder=&organizationId=&project=[[YOUR-PROJECT-ID]]

    您需要使用项目 ID 而不是项目编号 (6579173653)

    如果我怀疑您超出了(每天?每小时?)配额,您可以等待(直到这些重置)或申请更多:

    https://console.cloud.google.com/iam-admin/quotas?project=[[YOUR-PROJECT-ID]]&folder&organizationId&service=vision-json.googleapis.com

    您应该能够使用以下方法确定项目 ID:

    PROJECT_ID=$(\
      gcloud projects list \
      --filter="projectNumber~6579173653" \
      --format=value(projectId)") && echo ${PROJECT_ID}
    

    NB我不清楚为什么这只适用于~ 而不是=

    【讨论】:

      【解决方案2】:

      确保执行此步骤:export GOOGLE_APPLICATION_CREDENTIALS="[PATH]"

      【讨论】:

        猜你喜欢
        • 2019-10-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-11-02
        • 1970-01-01
        • 1970-01-01
        • 2017-12-03
        • 1970-01-01
        相关资源
        最近更新 更多