繁体   English   中英

Google Vision API错误代码

[英]Google Vision API Error Code

我正在尝试https://googlecloudplatform.github.io/google-cloud-python/stable/vision-usage.html中的示例代码

from google.cloud import vision
   client = vision.Client()
   image = client.image('./image.jpg')
   safe_search = image.detect_safe_search()

image.detect_safe_search对api返回的结果抛出键错误。 在打印结果字典时,我发现它没有预期的键,因为它给出了错误响应。 从Google api返回的响应是

{u'error': {u'message': u'image-annotator::error(12): Image processing error!', u'code': 13}}

我在api文档中找不到错误代码的任何引用。 我想念什么?

这是一个也提到该错误的问题 该问题已转发给Google工程团队。

您可以尝试重新编码图像吗? 将其另存为png或重新保存为jpg,以查看其是否已损坏或有其他问题?

看来文档不正确。

这个例子有效。

from google.cloud import vision

client = vision.Client()

with open('yourimage.jpg', 'rb') as file_obj:
    my_image = client.image(content=file_obj.read())
results = my_image.detect_safe_search()

print(results[0].medical)
# 'VERY_UNLIKELY'

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM