Google Vision API 的响应时间(文本检测 - OCR)

问题描述 投票:0回答:1

我在 Google Vision API 上的文本检测方面遇到问题,需要很长时间才能得到响应。当我在 Google Colab 上运行代码时,我会在 1-2 秒内得到答案,但当我在我的机器上运行时,需要 15 到 20 秒才能得到答案。

我使用的代码如下。

from google.cloud import vision
import io
client = vision.ImageAnnotatorClient()
timer_a=time.time()
with io.open(path, 'rb') as image_file:
    content = image_file.read()
timer_b=time.time()
image = vision.Image(content=content)

response = client.text_detection(image=image)
timer_c=time.time()
texts = response.text_annotations

Colab 上timer_c 和timer_b 之间的时间:1.7577033042907715

本地计算机上运行的timer_c和timer_b之间的时间:19.413997173309326

时差太大了。我想这可能是因为 Colab 可能在同一个云中运行。但我能否获得更接近 Colab 的响应时间?我没有在本地计算机上配置任何内容,有没有办法获得更快的响应时间?

google-cloud-platform google-cloud-ml google-cloud-vision google-vision
1个回答
0
投票

响应取决于图像大小和网络速度。就您而言,由于您发送的文件大小相同,因此互联网速度是主要问题。使用Google Cloud时,网络速度通常很快,响应速度也更快。此外,如果计算机的规格过时,可能会导致请求和响应缓慢

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.