From fa4f3d6463dc2a29ed746f06ed66f5c05b8ce7eb Mon Sep 17 00:00:00 2001 From: Erick Date: Fri, 22 Jul 2022 22:04:38 +0200 Subject: [PATCH] Create basic image recognition script --- src/vision-test.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/vision-test.py diff --git a/src/vision-test.py b/src/vision-test.py new file mode 100644 index 0000000..b9dbd9f --- /dev/null +++ b/src/vision-test.py @@ -0,0 +1,25 @@ +import io +import os + +# Imports the Google Cloud client library +from google.cloud import vision + +# Instantiates a client +client = vision.ImageAnnotatorClient() + +# The name of the image file to annotate +file_name = os.path.abspath('images/mmr.jpg') + +# Loads the image into memory +with io.open(file_name, 'rb') as image_file: + content = image_file.read() + +image = vision.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)