【问题标题】:Google cloud vision batch process of large number of images using python谷歌云视觉批量处理大量图片使用python
【发布时间】:2018-01-09 19:08:34
【问题描述】:

我是 python 和云视觉的新手。我需要标记大约 20k 图像。我的代码虽然可以工作,但需要大量时间来处理。有什么方法可以提高效率吗?任何帮助将不胜感激

filename=[]
description=[]
score=[]
for root, dirs, filenames in os.walk(indir):
    for f in filenames:
        if  f.endswith('.jpg'):
            file_name=indir+'/'+f

            with io.open(file_name, 'rb') as image_file:
                content = image_file.read()
            image = types.Image(content=content)
            response = client.label_detection(image=image)
            labels = response.label_annotations

            for label in labels:
                filename.append(f)
                description.append(label.description)
                score.append(label.score)

import pandas as pd

vision_op = pd.DataFrame(
    {'filename': filename,
     'description': description,
     'score': score
    })

【问题讨论】:

  • 我也想知道

标签: python computer-vision google-cloud-vision


【解决方案1】:

您可以从多个线程发送请求以加快速度。

由于 annotate 接受 multiple AnnotateImageRequests,因此您还可以在单​​个 API 调用中发送多个图像。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-28
    • 1970-01-01
    • 2016-06-02
    • 1970-01-01
    • 2019-12-07
    • 1970-01-01
    相关资源
    最近更新 更多