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

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

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

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

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

谢谢!

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

一种选择是使用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://www.codej.cn/res/2022/08-16/14/4e4ad0120d4fd4dd88ab7a9bb0957bee.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
        }
      ]
    }
  ]
}
本文链接:https://www.f2er.com/3160518.html

大家都在问