Response time on Google Vision API (text detection - OCR)

560 Views Asked by At

I'm having troubles with the text detection on Google Vision API, it's taking too long to get a response. When I run my code on Google Colab I get the answer between 1-2 seconds but when I run on my machine it takes 15 to 20 seconds to get the answer.

The code I'm using it's bellow.

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

Time between timer_c and timer_b on Colab: 1.7577033042907715

Time between timer_c and timer_b running on a local machine: 19.413997173309326

The time difference it's too big. I guess it could be because Colab might run in the same cloud. But could I get a response time closer to the Colab one ? I didn't configure anything on my local machine, it's there a way to get faster response times ?

0

There are 0 best solutions below