Skip to content

Commit

Permalink
chore(): increase the image size to enhance recognition accuracy
Browse files Browse the repository at this point in the history
  • Loading branch information
sunshinexcode committed Dec 11, 2024
1 parent 8ce9d8e commit b7663cd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def rgb2base64jpeg(rgb_data, width, height):
pil_image = pil_image.convert("RGB")

# Resize the image while maintaining its aspect ratio
pil_image = resize_image_keep_aspect(pil_image, 320)
pil_image = resize_image_keep_aspect(pil_image, 512)

# Save the image to a BytesIO object in JPEG format
buffered = BytesIO()
Expand Down Expand Up @@ -141,17 +141,17 @@ def get_tool_metadata(self, ten_env: AsyncTenEnv) -> list[LLMToolMetadata]:
],
),
]

async def run_tool(self, ten_env: AsyncTenEnv, name: str, args: dict) -> LLMToolResult:
if name == "get_vision_chat_completion":
if self.image_data is None:
raise Exception("No image data available")

if "query" not in args:
raise Exception("Failed to get property")

query = args["query"]

base64_image = rgb2base64jpeg(self.image_data, self.image_width, self.image_height)
# return LLMToolResult(message=LLMCompletionArgsMessage(role="user", content=[result]))
cmd: Cmd = Cmd.create(CMD_CHAT_COMPLETION_CALL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def rgb2base64jpeg(rgb_data, width, height):
pil_image = pil_image.convert("RGB")

# Resize the image while maintaining its aspect ratio
pil_image = resize_image_keep_aspect(pil_image, 320)
pil_image = resize_image_keep_aspect(pil_image, 512)

# Save the image to a BytesIO object in JPEG format
buffered = BytesIO()
Expand Down

0 comments on commit b7663cd

Please sign in to comment.