How to call for “Label Detection” and “Safe Search Detection” at a time on Google Cloud Vision API

拟墨画扇 提交于 2019-12-13 03:57:34

问题


I would like to ask you the the following thing about Vision API.

The following picture indicates that I can take on "Free with Label Detection, or $1.50", if I will use "Label Detection". But, I didn't find out how to use both of them at the same time in a tutorial on "Label Detection" and "Safe Search Detection" both.

  1. Can I use both of services at a time in Python?
  2. If so, how can I call for them?

I will really appreciate that if you tell me.


回答1:


In case you want to send both types at the same time, you can use the annotate_image() method; in this way, you can specify all the features that need to be included in the same request. Based on this, I recommend you to take a look on this documentation (Doc1, Doc2) to get detailed information about this property usage, as well as this tutorial, that contains a curl command example where is shown the process required to send multiple features within the same call that you can use as an alternative workaround.

import io
import os

from google.cloud import vision

client = vision.ImageAnnotatorClient()

response = client.annotate_image({
  'image': {'source': {'image_uri': '<IMAGE_URI>'}},
  'features': [{'type': vision.enums.Feature.Type.SAFE_SEARCH_DETECTION},
               {'type': vision.enums.Feature.Type.LABEL_DETECTION}]
})

print(response)

Additionally, I think that this pricing information refers that you can use the Safe Search Detection feature for free if you use it with Label Detection; however, the Label Detection requests will be billed with the corresponding charges that are displayed at the Prices document.



来源:https://stackoverflow.com/questions/53195930/how-to-call-for-label-detection-and-safe-search-detection-at-a-time-on-googl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!