@@ -0,0 +1,524 @@
+%22%22%22Converts image to Base64 for AI Platform ML API.%22%22%22%0A%0Aimport base64%0A%0AINPUT_FILE = 'image.jpg'%0AOUTPUT_FILE = 'image_b64.json'%0A%0Adef convert_to_base64(image_file):%0A  %22%22%22Open image and convert it to base64%22%22%22%0A  with open(image_file, 'rb') as f:%0A    jpeg_bytes = base64.b64encode(f.read()).decode('utf-8')%0A    predict_request = '%7B%22instances%22 : %5B%7B%22b64%22: %22%25s%22%7D%5D%7D' %25 jpeg_bytes%0A    # Write JSON to file%0A    with open(OUTPUT_FILE, 'w') as f:%0A      f.write(predict_request)%0A    return predict_request%0A%0Aconvert_to_base64(INPUT_FILE)%0A

Create convert_b64_api.py