Google表格:自动获取图像分类标签的公式,脚本或扩展名?

问题描述 投票:0回答:1

我有一个带有图像URL列表的Google表格。

[第一列:图片网址。第二列:描述图像的标签(例如:“景观,山,田野,日落,湖泊”,用于包含山,田野,日落等的风景图像)

我想用“ ImageTags(ImageUrl)”之类的公式自动填充第2列。

是否有任何公式,扩展名或脚本(已经可用:))?

谢谢!

google-sheets google-sheets-api google-sheets-formula google-apps google-vision
1个回答
0
投票

选项是使用Google Cloud Vision API标记图像。您可以测试API以确定它是否适合您的需求here

有两个使用Google Apps脚本来调用API的教程,可以帮助您开发所需的确切代码:

  1. Using a service account to authenticate, detect labels and send a GMail message

  2. Using oAuth2 to authenticate and label images

作为示例,使用以下图像:

enter image description here

并使用以下参数调用API:

  • HTTP请求

POST https://vision.googleapis.com/v1/images:annotate

  • 正文
{
  "requests": [
    {
      "image": {
        "source": {
          "imageUri": "https://i.stack.imgur.com/4vwKt.jpg"
        }
      },
      "features": [
        {
          "type": "LABEL_DETECTION"
        }
      ]
    }
  ]
}

您获得以下结果(2019年11月5日):

{
  "responses": [
    {
      "labelAnnotations": [
        {
          "mid": "/m/09j06",
          "description": "Hot air balloon",
          "score": 0.9889263,
          "topicality": 0.9889263
        },
        {
          "mid": "/m/01j51",
          "description": "Balloon",
          "score": 0.95322704,
          "topicality": 0.95322704
        },
        {
          "mid": "/m/02p81ht",
          "description": "Hot air ballooning",
          "score": 0.9223063,
          "topicality": 0.9223063
        },
        {
          "mid": "/m/0cmqr_4",
          "description": "Party supply",
          "score": 0.9016293,
          "topicality": 0.9016293
        },
        {
          "mid": "/m/01d40f",
          "description": "Dress",
          "score": 0.86037284,
          "topicality": 0.86037284
        },
        {
          "mid": "/m/07yv9",
          "description": "Vehicle",
          "score": 0.7725018,
          "topicality": 0.7725018
        },
        {
          "mid": "/m/01bqvp",
          "description": "Sky",
          "score": 0.7326111,
          "topicality": 0.7326111
        },
        {
          "mid": "/m/0ds99lh",
          "description": "Fun",
          "score": 0.7039424,
          "topicality": 0.7039424
        },
        {
          "mid": "/m/016pp7",
          "description": "Happy",
          "score": 0.6789371,
          "topicality": 0.6789371
        },
        {
          "mid": "/m/06bm2",
          "description": "Recreation",
          "score": 0.6695586,
          "topicality": 0.6695586
        }
      ]
    }
  ]
}
© www.soinside.com 2019 - 2024. All rights reserved.