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