Skip to content

Instantly share code, notes, and snippets.

@esenthil2018
Created October 25, 2020 02:10
Show Gist options
  • Save esenthil2018/5ebea27b63e12575855cf6fd7f2d6d76 to your computer and use it in GitHub Desktop.
Save esenthil2018/5ebea27b63e12575855cf6fd7f2d6d76 to your computer and use it in GitHub Desktop.
#Sample code to use the google API
from google.cloud import vision
from google.cloud.vision import types
import os
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "keyFile.json"
def vision(url):
image = types.Image()
image.source.image_uri = url
#client = vision.ImageAnnotatorClient()
label_results = client.label_detection(image=image)
for label in label_results.label_annotations:
#print(f'{label.description} - {label.score}')
label1 = label.description
return label1
break
from google.cloud import vision
from google.cloud.vision import types
rlabel = []
client = vision.ImageAnnotatorClient()
image = types.Image()
for row in insta_df['Url']:
image.source.image_uri = row
label_results = client.label_detection(image=image)
for label in label_results.label_annotations:
label1 = label.description
rlabel.append(label1)
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment