0

I'm using a Raspberry Pi 2 to upload a test image to both AWS and Google Cloud. Google takes 3 seconds to return a label response. Amazon takes 1 second.

Amazon Rekognition Results:

pi@raspberrypi:~ $ python amazon-detect.py
> People 
> 1.18470716476

Google Cloud Vision Results:

pi@raspberrypi:~ $ python glabel.py
> people
> 3.31247806549

Here's the 2 python files that I'm using:

amazon-detect.py

#!/usr/bin/env python
import boto3
import json
import time


rekonize = boto3.client(
    'rekognition',
    aws_access_key_id='xx',
    aws_secret_access_key='xx',
    region_name='us-east-1',
)

start = time.time()

with open("/home/pi/group.jpg", "rb") as f:
    data = f.read()
    response = rekonize.detect_labels(Image={'Bytes': data,},MaxLabels=1,MinConfidence=80,)

array = json.dumps(response)
a = json.loads(array)
print a['Labels'][0]["Name"]

timer = time.time() - start
print timer

glabel.py

#!/usr/bin/env python
import os
import time
import json

# Imports the Google Cloud client library
from google.cloud import vision

# Instantiates a client
client = vision.Client()

start = time.time() 

# Loads the image into memory
with open("/home/pi/group.jpg", "rb") as image_file:
    content = image_file.read()
    image = client.image(content=content)
    labels = image.detect_labels(limit=1)

for label in labels:
    print label.description

timer = time.time() - start
print timer

How can I improve the speed of Google Cloud Vision's response? Thank you in advance for any tips!

edit 1:

I'm now using the cURL api for Cloud Vision. Results are much better!

pi@raspberrypi:~ $ python glabel-curl.py
people
1.2390229702

edit 2:

For reference, I moved the timer code to start at the beginning each python file. This gives me a better idea of the response speed:

pi@raspberrypi:~ $ python glabel-curl.py
people
1.27051591873
pi@raspberrypi:~ $ python glabel.py
people
7.16125893593
pi@raspberrypi:~ $ python amazon-detect.py
People
1.57734918594
Entryton
  • 57
  • 1
  • 2
  • 9
  • 1
    There's no reason to believe they are using the same technology, so there's no reason to believe they should be expected to perform the same. Fire up a virtual server within the Google Cloud and test from there. See what you see. It could simply be slower. – Michael - sqlbot Nov 15 '17 at 03:41
  • From what I can tell, Google cloud is slower if I use the client. It's faster if I use cURL. – Entryton Nov 15 '17 at 03:58
  • Probably some sloppy code in the client. That's quite a discrepancy. – Michael - sqlbot Nov 15 '17 at 04:05
  • Yes, that's probably what it is. I tested a 3rd service: Azure Computer Vision and it's faster than Amazon and Google. So I will go with Azure. – Entryton Nov 15 '17 at 23:27
  • @Entryton Thats good insight. Did you check with a set of images rather than just one image ? Also, have you tried images with multiple objects and compared the runtime and objects detected ? I would be interested to see the comparison result. – ExtractTable.com Nov 22 '17 at 18:06

0 Answers0