INNER CODE UNIT · Python

__init__

instavm/clickclickclick · clickclickclick/finder/__init__.py:29

    def __init__(self, api_key, model_name, generation_config, system_prompt, executor: Executor):
        self.model_name = model_name
        self.generation_config = generation_config
        self.system_prompt = system_prompt
        self.executor = executor

    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

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…