-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
399d3fb
commit d512121
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |