INNER CODE UNIT · Python
encode_image_to_base64
instavm/clickclickclick · clickclickclick/finder/__init__.py:35
def encode_image_to_base64(self, image_path):
with open(image_path, "rb") as image_file:
encoded_string = base64.b64encode(image_file.read()).decode("utf-8")
return encoded_string
def resize(self, image, new_size):
if new_size:
target_width, target_height = new_size, new_size
resized_image = image.resize((target_width, target_height), Image.Resampling.LANCZOS)
segments = [(resized_image, (0, 0, target_width, target_height))]
total_width, total_height = target_width, target_height
return segments, total_width, total_height
@abstractmethod
def process_segment(self, segment, model, prompt):
pass
def find_element(self, prompt, observation: str) -> str: