Skip to content

Instantly share code, notes, and snippets.

@junwin
Created March 22, 2023 19:13
Show Gist options
  • Save junwin/de3ddc5e0cfcdd3190e619a88e3db7cd to your computer and use it in GitHub Desktop.
Save junwin/de3ddc5e0cfcdd3190e619a88e3db7cd to your computer and use it in GitHub Desktop.
os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = 'G:\My Drive\credential\your_credentials.json'
work_dir = 'C:/temp/2023Mar/Output/web'
from google.cloud import vision
def anotate_image(file_name):
client = vision.ImageAnnotatorClient()
with io.open(file_name, 'rb') as image_file:
content = image_file.read()
image = vision.Image(content=content)
# Perform label detection on the image file
response = client.label_detection(image=image)
labels = response.label_annotations
return labels
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment