import io, sys, os # Imports the Google Cloud client library from google.cloud import vision from google.cloud.vision import types # Instantiates a client client = vision.ImageAnnotatorClient() # The name of the image file to annotate path = os.path.join(sys.path[0], 'DSC_6315.jpg') # Loads the image into memory with io.open(path, '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([label.description for label in labels])