<commit_before>import base64

INPUT_FILE = 'image.jpg'
OUTPUT_FILE = '/tmp/image_b64.json'

"""Open image and convert it to Base64"""
with open(INPUT_FILE, 'rb') as f:
  jpeg_bytes = base64.b64encode(f.read()).decode('utf-8')
  predict_request = '{"image_bytes": {"b64": "%s"}}' % jpeg_bytes
  # Write JSON to file
  with open(OUTPUT_FILE, 'w') as f:
    f.write(predict_request)<commit_msg>Update convert_b64.py<commit_after>import base64

INPUT_FILE = 'image.jpg'
OUTPUT_FILE = '/tmp/image_b64.json'

"""Open image and convert it to Base64"""
with open(INPUT_FILE, 'rb') as input_file:
  jpeg_bytes = base64.b64encode(input_file.read()).decode('utf-8')
  predict_request = '{"image_bytes": {"b64": "%s"}}' % jpeg_bytes
  # Write JSON to file
  with open(OUTPUT_FILE, 'w') as output_file:
    output_file.write(predict_request)
{'fraction_non_alphanumeric': 0.15821256038647344, 'fraction_numerical': 0.033816425120772944, 'mean_word_length': 5.426356589147287, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4520903', 'n_tokens_mistral': 318, 'n_tokens_neox': 299, 'n_words': 70}