attribution / llm_api /utils.py
thanhnt-cf's picture
initial commit
7a38b33
raw
history blame contribute delete
335 Bytes
import base64
def get_image_data(image_path):
with open(image_path, "rb") as f:
image_data = base64.b64encode(f.read()).decode("utf-8")
return image_data
def get_data_format(image_path):
image_format = image_path.split(".")[-1]
if image_format == "jpg":
image_format = "jpeg"
return image_format