Skip to content

Commit

Permalink
test api
Browse files Browse the repository at this point in the history
  • Loading branch information
NadaRadwan committed Feb 17, 2018
1 parent 399d3fb commit d512121
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions testAPI.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import io
import os

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

def getCredentials():
storage_client = storage.Client.from_service_account_json(
'eyeHear-cad56858f9be.json')
return storage_client
# buckets = list(storage_client.list_buckets())
# print(buckets)

def instantiateClient():
# Instantiates a client
client = vision.ImageAnnotatorClient(
credentials=getCredentials())

# The name of the image file to annotate
file_name = os.path.join(
os.path.dirname(__file__),
'images/demo-image.jpg')

# Loads the image into memory
with io.open(file_name, 'rb') as image_file:
content = image_file.read()

image = types.Image(content=content)

# Performs label detection on the image file
response = client.label_detection(image=image)
# labels = response.label_annotations

# print('Labels:')
# for label in labels:
# print(label.description)

instantiateClient()

0 comments on commit d512121

Please sign in to comment.