1 回答

TA貢獻1826條經(jīng)驗 獲得超6個贊
由于異步模式支持“TEXT_DETECTION”功能,因此可以離線使用批量圖像注釋。您可以在此處找到 Python 的示例代碼,如您所見,需要為每個圖像創(chuàng)建一個請求元素并將其添加到請求數(shù)組中:
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)
添加回答
舉報