Skip to content

Instantly share code, notes, and snippets.

View internetmosquito's full-sized avatar

Alejandro Villamarin internetmosquito

View GitHub Profile
@internetmosquito
internetmosquito / gist:b1c1f00ac99d9aa1f79cfdc21be36b5b
Last active June 11, 2018 10:32
How to encode images for Google Cloud Vision
images_names = list()
for iterator, image_file in enumerate(images):
image_path = os.path.join(folder_name, image_file)
images_names.append(self.path_leaf(image_path))
self.images_names.append(self.path_leaf(image_path))
with open(image_path, 'rb') as image:
image_content = base64.b64encode(image.read())
image_payload = {}
image_payload['image'] = {}
image_payload['image']['content'] = image_content.decode('UTF-8')