<filename>API/GCP_api/image/test_use.py
"""
# @Time    :  2020/8/11
# @Author  :  <NAME>
"""
import io
import os

# Imports the Google Cloud client library
from google.cloud import vision
from google.cloud.vision import types
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "D:/App/API/wellnet.json"

# Instantiates a client
client = vision.ImageAnnotatorClient()

# The name of the image file to annotate
file_name = os.path.abspath('test1.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)
<filename>API/GCP_api/image/test_use.py
"""
# @Time    :  2020/8/11
# @Author  :  <NAME>
"""
import io
import os

# Imports the Google Cloud client library
from google.cloud import vision
from google.cloud.vision import types
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "D:/App/API/wellnet.json"

# Instantiates a client
client = vision.ImageAnnotatorClient()

# The name of the image file to annotate
file_name = os.path.abspath('test1.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)
# @Time    :  2020/8/11 # @Author  :  <NAME> # Imports the Google Cloud client library # Instantiates a client # The name of the image file to annotate # Loads the image into memory # Performs label detection on the image file