1 回答
TA贡献1826条经验 获得超6个赞
由于异步模式支持“TEXT_DETECTION”功能,因此可以离线使用批量图像注释。您可以在此处找到 Python 的示例代码,如您所见,需要为每个图像创建一个请求元素并将其添加到请求数组中:
client = vision_v1.ImageAnnotatorClient()
//image one
source1 = {"image_uri": image_uri_1}
image1 = {"source": source1}
features1 = [
{"type": enums.Feature.Type.LABEL_DETECTION},
{"type": enums.Feature.Type.IMAGE_PROPERTIES}
]
//image two
source2 = {"image_uri": image_uri_2}
image2 = {"source": source2}
features2 = [
{"type": enums.Feature.Type.LABEL_DETECTION}
]
# Each requests element corresponds to a single image
requests = [{"image": image1, "features": features1}, {"image": image2, "features": features2}]
gcs_destination = {"uri": output_uri}
# The max number of responses to output in each JSON file
batch_size = 2
output_config = {"gcs_destination": gcs_destination,
"batch_size": batch_size}
operation = client.async_batch_annotate_images(requests, output_config)
添加回答
举报