Files
OmniParser/omnitool/gradio/agent/llm_utils/utils.py
Thomas Dhome-Casanova fe84a35292 Naming conventions
2025-02-04 11:43:36 -08:00

13 lines
396 B
Python

import base64
def is_image_path(text):
image_extensions = (".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".tif")
if text.endswith(image_extensions):
return True
else:
return False
def encode_image(image_path):
"""Encode image file to base64."""
with open(image_path, "rb") as image_file:
return base64.b64encode(image_file.read()).decode("utf-8")